#include <vector3.h>
Public Member Functions | |
Vector3 () | |
Initializes all coordinates to 0. | |
Vector3 (float c) | |
Initializes all coordinates to the given value c. | |
Vector3 (float _x, float _y, float _z) | |
Initializes each coordinate to the corresponding given values. | |
Vector3 (const Point3 &p) | |
Initialize each coordinate to the corresponding cooridnate of the given point p. | |
Vector3 | operator+ (const Vector3 &v) const |
Add this and the given vector v together and then return the result. | |
Vector3 & | operator+= (const Vector3 &v) |
Add this and the given vector v together and set this to the result. | |
Vector3 | operator- (const Vector3 &v) const |
Subtract this with v and return the result. | |
Vector3 & | operator-= (const Vector3 &v) |
Subtract this with v and set this to the result. | |
bool | operator== (const Vector3 &v) const |
Check if this is equal to v or not. | |
Vector3 | operator* (float f) const |
Multiply this with the given real number f and return the result. | |
Vector3 & | operator*= (float f) |
Multiply this with the given real number f and set this to the result. | |
Vector3 | operator/ (float f) const |
Divide this by the given real number f (which must not be zero) and return the result. | |
Vector3 & | operator/= (float f) |
Divde this by the given real number f (which must not be zero) and set this to the result. | |
Vector3 | operator- () const |
Return the negative of this. | |
float | operator[] (int i) const |
Return the ith component of this. | |
bool | operator!= (const Vector3 &other) const |
Check if this is not equal to the given vector other. | |
float & | operator[] (int i) |
Return the reference to the ith component of this. | |
void | fill_array_3 (float *a) |
Fill the given 3-element array with the vector's coordinates. | |
void | fill_array_4 (float *a) |
Fill the given 4-element array with the vector's homogeneous coordinates. | |
float | length_squared () const |
Return the square of the length of this. | |
float | length () const |
Return the length of this. | |
bool | is_near (const Vector3 &other, float threshold=EPSILON) const |
Check if each coordinate of this is within threshold (a real number) of the corresponding coordinate of other. | |
Public Attributes | |
float | x |
The x coordinate. | |
float | y |
The y coordinate. | |
float | z |
The z coordinate. |
Vector3::Vector3 | ( | ) | [inline] |
Initializes all coordinates to 0.
Vector3::Vector3 | ( | float | c | ) | [inline] |
Initializes all coordinates to the given value c.
Vector3::Vector3 | ( | float | _x, | |
float | _y, | |||
float | _z | |||
) | [inline] |
Initializes each coordinate to the corresponding given values.
_x | the initial x coordinate | |
_y | the initial y coordinate | |
_z | the initial z coordinate |
Vector3::Vector3 | ( | const Point3 & | p | ) | [explicit] |
Initialize each coordinate to the corresponding cooridnate of the given point p.
void Vector3::fill_array_3 | ( | float * | a | ) | [inline] |
Fill the given 3-element array with the vector's coordinates.
That is:
a
[0] will be set to the x coordinate.a
[1] will be set to the y coordinate.a
[2] will be set to the z coordinate. void Vector3::fill_array_4 | ( | float * | a | ) | [inline] |
Fill the given 4-element array with the vector's homogeneous coordinates.
That is:
a
[0] will be set to the x coordinate.a
[1] will be set to the y coordinate.a
[2] will be set to the z coordinate.a
[3] will be set to 0. bool Vector3::is_near | ( | const Vector3 & | other, | |
float | threshold = EPSILON | |||
) | const [inline] |
Check if each coordinate of this is within threshold (a real number) of the corresponding coordinate of other.
Use this method to test approximate equality.
float Vector3::length | ( | ) | const [inline] |
Return the length of this.
float Vector3::length_squared | ( | ) | const [inline] |
Return the square of the length of this.
bool Vector3::operator!= | ( | const Vector3 & | other | ) | const [inline] |
Check if this is not equal to the given vector other.
Vector3 Vector3::operator* | ( | float | f | ) | const [inline] |
Multiply this with the given real number f and return the result.
Vector3& Vector3::operator*= | ( | float | f | ) | [inline] |
Multiply this with the given real number f and set this to the result.
Add this and the given vector v together and then return the result.
Add this and the given vector v together and set this to the result.
Vector3 Vector3::operator- | ( | ) | const [inline] |
Return the negative of this.
Subtract this with v and return the result.
Subtract this with v and set this to the result.
Vector3 Vector3::operator/ | ( | float | f | ) | const [inline] |
Divide this by the given real number f (which must not be zero) and return the result.
Vector3& Vector3::operator/= | ( | float | f | ) | [inline] |
Divde this by the given real number f (which must not be zero) and set this to the result.
bool Vector3::operator== | ( | const Vector3 & | v | ) | const [inline] |
Check if this is equal to v or not.
float& Vector3::operator[] | ( | int | i | ) | [inline] |
Return the reference to the ith component of this.
This method is provided so that you can do something like this:
Vector3 a; a[0] = 1.0f; a[1] = 1.5f; a[2] = 2.0f;
The components are indexed as follows:
float Vector3::operator[] | ( | int | i | ) | const [inline] |
Return the ith component of this.
The components are indexed as follows:
float Vector3::x |
The x coordinate.
float Vector3::y |
The y coordinate.
float Vector3::z |
The z coordinate.