source: anuga_work/development/anugavis/src/vector.cc @ 5685

Last change on this file since 5685 was 5636, checked in by jack, 17 years ago

Almost ready to run.

File size: 956 bytes
Line 
1#include "vector.hh"
2
3Vector &Vector::operator += (const Vector &other){
4  this->x += other.x;
5  this->y += other.y;
6  this->z += other.z;
7  return *this;
8}
9
10Vector Vector::operator + (const Vector &other) const{
11  return Vector(*this) += other;
12}
13
14Vector &Vector::operator -= (const Vector &other){
15  return *this += other.scale(-1);
16}
17
18Vector Vector::operator - (const Vector &other) const{
19  return Vector(*this) -= other;
20}
21
22Vector Vector::cross(const Vector &other) const{
23  return Vector(this->y * other.z - this->z * other.y,
24                this->z * other.x - this->x * other.z,
25                this->x * other.y - this->y * other.x);
26}
27
28float Vector::dot(const Vector &other) const{
29  return this->x * other.x + this->y * other.y + this->z * other.z;
30}
31
32float Vector::magnitude(void) const{
33  return this->dot(*this);
34}
35
36Vector Vector::scale(float amount) const{
37  return Vector(this->x * amount, this->y * amount, this->z * amount);
38}
Note: See TracBrowser for help on using the repository browser.