A 3-dimensional double vector and methods to operate on them. More...
#include <matvec3D.h>
Public Member Functions | |
double | len () const |
double | len_sq () const |
vec3 const & | operator*= (double s) |
vec3 const & | operator+= (vec3 const &v) |
vec3 const & | operator-= (vec3 const &v) |
vec3 const & | operator/= (double s) |
bool | operator< (vec3 const &v) const |
vec3 const & | operator= (vec3 const &v) |
bool | operator== (vec3 const &v) const |
double & | operator[] (int i) |
const double & | operator[] (int i) const |
void | perpVectors (vec3 &v1, vec3 &v2) |
void | set (const SbVec3f &v) |
void | set (double x, double y, double z) |
void | set (double v[3]) |
void | set (const vec3 &v) |
SbVec3f | toSbVec3f () const |
void | toSbVec3f (SbVec3f &v) const |
vec3 (double x, double y, double z) | |
vec3 (const SbVec3f &v) | |
vec3 (double v[3]) | |
vec3 (const vec3 &v) | |
vec3 () | |
double & | x () |
double | x () const |
double & | y () |
double | y () const |
double & | z () |
double | z () const |
Static Public Attributes | |
static const vec3 | X |
The vector [1,0,0]. | |
static const vec3 | Y |
The vector [0,1,0]. | |
static const vec3 | Z |
The vector [0,0,1]. | |
static const vec3 | ZERO |
The vector [0,0,0]. | |
Private Attributes | |
double | vec [3] |
Storarge for the 3 vector coordinates. | |
Friends | |
vec3 | normalise (vec3 const &v) |
double | operator% (vec3 const &v, position const &p) |
double | operator% (position const &p, vec3 const &v) |
double | operator% (vec3 const &v1, vec3 const &v2) |
vec3 | operator* (vec3 const &v1, vec3 const &v2) |
vec3 | operator* (vec3 const &v, transf const &tr) |
vec3 | operator* (mat3 const &m, vec3 const &v) |
vec3 | operator* (vec3 const &v, double s) |
vec3 | operator* (double s, vec3 const &v) |
vec3 | operator+ (vec3 const &v1, vec3 const &v2) |
vec3 | operator- (vec3 const &v) |
vec3 | operator- (vec3 const &v1, vec3 const &v2) |
vec3 | operator/ (vec3 const &v, double s) |
std::ostream & | operator<< (std::ostream &os, const vec3 &v) |
vec3 | operator> (vec3 const &v, transf const &tr) |
std::istream & | operator>> (std::istream &is, vec3 &v) |
A 3-dimensional double vector and methods to operate on them.
vec3 is stored as an array of 3 doubles.
Definition at line 53 of file matvec3D.h.
vec3::vec3 | ( | ) | [inline] |
Default constructor, vector is uninitialized.
Definition at line 60 of file matvec3D.h.
vec3::vec3 | ( | const vec3 & | v | ) | [inline] |
Copy constructor.
Definition at line 63 of file matvec3D.h.
vec3::vec3 | ( | double | v[3] | ) | [inline] |
Initializes the vector with the three values in the array v.
Definition at line 66 of file matvec3D.h.
vec3::vec3 | ( | const SbVec3f & | v | ) | [inline] |
Initializes the vector with the values from the Inventor vector v.
Definition at line 69 of file matvec3D.h.
vec3::vec3 | ( | double | x, | |
double | y, | |||
double | z | |||
) | [inline] |
Initializes the vector with the values x,y,z.
Definition at line 72 of file matvec3D.h.
double vec3::len | ( | ) | const [inline] |
Returns the length of this vector.
Definition at line 612 of file matvec3D.h.
double vec3::len_sq | ( | ) | const [inline] |
Returns the squared length of this vector.
Definition at line 621 of file matvec3D.h.
vec3 const & vec3::operator*= | ( | double | s | ) | [inline] |
Scales this vector by s.
Definition at line 636 of file matvec3D.h.
Adds vector v to this vector.
Definition at line 659 of file matvec3D.h.
Subtract vector v from this vector.
Definition at line 667 of file matvec3D.h.
vec3 const & vec3::operator/= | ( | double | s | ) | [inline] |
Scales this vector by 1/s.
Definition at line 675 of file matvec3D.h.
bool vec3::operator< | ( | vec3 const & | v | ) | const [inline] |
Compares 2 vectors lexigraphically. Returns true if this vector comes before vector v. Vectors are ordered on z axis then y and then x.
Definition at line 695 of file matvec3D.h.
Copies the vector v.
Definition at line 628 of file matvec3D.h.
bool vec3::operator== | ( | vec3 const & | v | ) | const [inline] |
Compares if 2 vectors are within resabs distance from each other.
Definition at line 683 of file matvec3D.h.
double& vec3::operator[] | ( | int | i | ) | [inline] |
Returns a reference to the value at index i.
Definition at line 78 of file matvec3D.h.
const double& vec3::operator[] | ( | int | i | ) | const [inline] |
Returns a constant reference to the value at index i.
Definition at line 75 of file matvec3D.h.
Returns two vectors that are perpendicular to this vector and each other.
Definition at line 61 of file matvec.cpp.
void vec3::set | ( | const SbVec3f & | v | ) | [inline] |
Sets the values in this vector with the values from the Inventor vector v.
Definition at line 553 of file matvec3D.h.
void vec3::set | ( | double | x, | |
double | y, | |||
double | z | |||
) | [inline] |
Sets the 3 values in this vector to x, y, z.
Definition at line 87 of file matvec3D.h.
void vec3::set | ( | double | v[3] | ) | [inline] |
Sets the 3 values in this vector to the 3 values in the array v.
Definition at line 84 of file matvec3D.h.
void vec3::set | ( | const vec3 & | v | ) | [inline] |
Copies vector v.
Definition at line 81 of file matvec3D.h.
SbVec3f vec3::toSbVec3f | ( | ) | const [inline] |
Converts this vector into an Inventor vector and returns it.
Definition at line 576 of file matvec3D.h.
void vec3::toSbVec3f | ( | SbVec3f & | v | ) | const [inline] |
Converts the values of this vector into floats and stores them in the provided Inventor vector.
Definition at line 565 of file matvec3D.h.
double& vec3::x | ( | ) | [inline] |
Returns a reference to the x-coordinate of this vector.
Definition at line 118 of file matvec3D.h.
double vec3::x | ( | ) | const [inline] |
Returns the x-coordinate of this vector.
Definition at line 109 of file matvec3D.h.
double& vec3::y | ( | ) | [inline] |
Returns a reference to the y-coordinate of this vector.
Definition at line 121 of file matvec3D.h.
double vec3::y | ( | ) | const [inline] |
Returns the y-coordinate of this vector.
Definition at line 112 of file matvec3D.h.
double& vec3::z | ( | ) | [inline] |
Returns a reference to the z-coordinate of this vector.
Definition at line 124 of file matvec3D.h.
double vec3::z | ( | ) | const [inline] |
Returns the z-coordinate of this vector.
Definition at line 115 of file matvec3D.h.
Returns a new unit vector that is the normalized version of vector v.
Definition at line 779 of file matvec3D.h.
Returns the dot product of vector v and position p.
Definition at line 720 of file matvec3D.h.
Returns the dot product of vector v and position p.
Definition at line 713 of file matvec3D.h.
Returns the dot product of vectors v1 and v2.
Definition at line 585 of file matvec3D.h.
Returns the cross product of vectors v1 and v2 ( v1 x v2 ).
Definition at line 739 of file matvec3D.h.
Returns a vector that is the result of rotating vector v using transform tr.
Definition at line 1328 of file matvec3D.h.
Definition at line 727 of file matvec3D.h.
Returns a new vector that is the result of scaling this vector by s.
Definition at line 603 of file matvec3D.h.
Returns a new vector that is the result of scaling this vector by s.
Definition at line 594 of file matvec3D.h.
Returns the sum of vectors v1 and v2.
Definition at line 748 of file matvec3D.h.
Returns a vector that is the negative of vector v. (unary minus)
Definition at line 764 of file matvec3D.h.
Returns the difference between vectors v1 and v2.
Definition at line 756 of file matvec3D.h.
Returns a new vector that is the result of scaling this vector by 1/s.
Definition at line 772 of file matvec3D.h.
std::ostream& operator<< | ( | std::ostream & | os, | |
const vec3 & | v | |||
) | [friend] |
Writes the values of vector v to a stream os in the format "[#, #, #]".
Definition at line 425 of file matvec.cpp.
Definition at line 1334 of file matvec3D.h.
std::istream& operator>> | ( | std::istream & | is, | |
vec3 & | v | |||
) | [friend] |
Reads the values of a vector v from stream is formatted as "[#, #, #]"
Definition at line 407 of file matvec.cpp.
double vec3::vec[3] [private] |
Storarge for the 3 vector coordinates.
Definition at line 56 of file matvec3D.h.
The vector [1,0,0].
Definition at line 155 of file matvec3D.h.
The vector [0,1,0].
Definition at line 158 of file matvec3D.h.
The vector [0,0,1].
Definition at line 161 of file matvec3D.h.
const vec3 vec3::ZERO [static] |
The vector [0,0,0].
Definition at line 152 of file matvec3D.h.