Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
|
#include <opvector3.h>
Public Member Functions | |
csVector3 () | |
csVector3 (float m) | |
csVector3 (float ix, float iy, float iz=0) | |
Make a new vector and initialize with the given values. More... | |
csVector3 (const csVector3 &v) | |
Copy Constructor. More... | |
csVector3 (const Vector v) | |
csVector3 | operator+ (const csVector3 &v2) const |
csVector3 | operator- (const csVector3 &v2) const |
Subtract two vectors. More... | |
void | Cross (const csVector3 &px, const csVector3 &py) |
Take cross product of two vectors and put result in this vector. More... | |
void | Cross (const Opcode::Point &px, const Opcode::Point &py) |
float | operator[] (int n) const |
Returns n-th component of the vector. More... | |
float & | operator[] (int n) |
Returns n-th component of the vector. More... | |
csVector3 & | operator+= (const csVector3 &v) |
Add another vector to this vector. More... | |
csVector3 & | operator-= (const csVector3 &v) |
Subtract another vector from this vector. More... | |
csVector3 & | operator*= (float f) |
Multiply this vector by a scalar. More... | |
csVector3 & | operator/= (float f) |
Divide this vector by a scalar. More... | |
csVector3 | operator+ () const |
Unary + operator. More... | |
csVector3 | operator- () const |
Unary - operator. More... | |
void | Set (float sx, float sy, float sz) |
Set the value of this vector. More... | |
void | Set (const csVector3 &v) |
Set the value of this vector. More... | |
float | Norm () const |
Returns the norm of this vector. More... | |
float | SquaredNorm () const |
Return the squared norm (magnitude) of this vector. More... | |
csVector3 | Unit () const |
void | Normalize () |
Scale this vector to length = 1.0;. More... | |
bool | IsZero () const |
Query if the vector is zero. More... | |
Static Public Member Functions | |
static float | Norm (const csVector3 &v) |
Returns the norm (magnitude) of a vector. More... | |
static csVector3 | Unit (const csVector3 &v) |
Normalizes a vector to a unit vector. More... | |
Public Attributes | |
float | x |
The X component of the vector. More... | |
float | y |
The Y component of the vector. More... | |
float | z |
The Z component of the vector. More... | |
Friends | |
float | operator* (const csVector3 &v1, const csVector3 &v2) |
Subtract two vectors of differing type, cast to double. More... | |
csVector3 | operator% (const csVector3 &v1, const csVector3 &v2) |
Take the cross product of two vectors. More... | |
csVector3 | operator* (const csVector3 &v, float f) |
Multiply a vector and a scalar. More... | |
csVector3 | operator* (float f, const csVector3 &v) |
Multiply a vector and a scalar. More... | |
csVector3 | operator* (const csVector3 &v, int f) |
Multiply a vector and a scalar int. More... | |
csVector3 | operator* (int f, const csVector3 &v) |
Multiply a vector and a scalar int. More... | |
csVector3 | operator/ (const csVector3 &v, float f) |
Divide a vector by a scalar. More... | |
csVector3 | operator/ (const csVector3 &v, int f) |
Divide a vector by a scalar int. More... | |
bool | operator== (const csVector3 &v1, const csVector3 &v2) |
Check if two vectors are equal. More... | |
bool | operator!= (const csVector3 &v1, const csVector3 &v2) |
Check if two vectors are not equal. More... | |
csVector3 | operator>> (const csVector3 &v1, const csVector3 &v2) |
Project one vector onto another. More... | |
csVector3 | operator<< (const csVector3 &v1, const csVector3 &v2) |
Project one vector onto another. More... | |
bool | operator< (const csVector3 &v, float f) |
Test if each component of a vector is less than a small epsilon value. More... | |
bool | operator> (float f, const csVector3 &v) |
Test if each component of a vector is less than a small epsilon value. More... | |
A 3D vector.
Definition at line 28 of file opvector3.h.
|
inline |
Make a new vector. The vector is not initialized. This makes the code slightly faster as csVector3 objects are used a lot.
Definition at line 43 of file opvector3.h.
Referenced by operator+(), and operator-().
|
inline |
Make a new initialized vector. Creates a new vector and initializes it to m*<1,1,1>. To create a vector initialized to the zero vector, use csVector3(0)
Definition at line 50 of file opvector3.h.
Make a new vector and initialize with the given values.
Definition at line 53 of file opvector3.h.
|
inline |
|
inline |
Take cross product of two vectors and put result in this vector.
Definition at line 84 of file opvector3.h.
Referenced by ContinuousTerrain::Collide(), and Unit::InsideCollideTree().
|
inline |
|
inline |
float csVector3::Norm | ( | ) | const |
Returns the norm (magnitude) of a vector.
Definition at line 209 of file opvector3.h.
References Norm().
void csVector3::Normalize | ( | ) |
Scale this vector to length = 1.0;.
Definition at line 34 of file opvector3.cpp.
References qisqrt, SMALL_EPSILON, x, y, and z.
Referenced by ContinuousTerrain::Collide(), and Unit::InsideCollideTree().
|
inline |
|
inline |
Set the value of this vector.
Definition at line 189 of file opvector3.h.
Referenced by csOPCODECollider::Collide().
|
inline |
|
inline |
|
inline |
Returns the unit vector in the direction of this vector. Attempting to normalize a zero-vector will result in a divide by zero error. This is as it should be... fix the calling code.
Definition at line 206 of file opvector3.h.
References Norm().
Referenced by Unit().
Normalizes a vector to a unit vector.
Definition at line 212 of file opvector3.h.
References Unit().
Project one vector onto another.
Definition at line 137 of file opvector3.h.
Project one vector onto another.
Definition at line 133 of file opvector3.h.
float csVector3::x |
The X component of the vector.
Definition at line 32 of file opvector3.h.
Referenced by csBox3::AddBoundingVertex(), csBox3::AddBoundingVertexSmart(), csBox3::Between(), ContinuousTerrain::Collide(), csOPCODECollider::Collide(), csBox3::Contains(), Cross(), csTerrainSegmentCellCollider::csTerrainSegmentCellCollider(), csBox3::Empty(), csBox3::GetCenter(), csBox3::GetConvexOutline(), csTerrainSegmentCellCollider::GetIntersection(), csBox3::GetVisibleSides(), csBox3::In(), Unit::InsideCollideTree(), IsZero(), csBox3::ManhattanDistance(), csBox3::Max(), csBox3::MaxX(), csBox3::Min(), csBox3::MinX(), Norm(), Normalize(), operator!=(), operator*(), operator*=(), csBox3::operator*=(), operator+(), operator+(), operator+=(), csBox3::operator+=(), operator-(), operator-=(), operator/=(), operator<(), operator==(), operator>(), operator[](), csBox3::Overlap(), Set(), csBox3::Set(), SquaredNorm(), csBox3::SquaredOriginDist(), csBox3::SquaredOriginMaxDist(), and csBox3::StartBoundingBox().
float csVector3::y |
The Y component of the vector.
Definition at line 34 of file opvector3.h.
Referenced by csBox3::AddBoundingVertex(), csBox3::AddBoundingVertexSmart(), csBox3::Between(), ContinuousTerrain::Collide(), csOPCODECollider::Collide(), csBox3::Contains(), Cross(), csTerrainSegmentCellCollider::csTerrainSegmentCellCollider(), csBox3::Empty(), csBox3::GetCenter(), csBox3::GetConvexOutline(), csTerrainSegmentCellCollider::GetIntersection(), csBox3::GetVisibleSides(), csBox3::In(), Unit::InsideCollideTree(), IsZero(), csBox3::ManhattanDistance(), csBox3::Max(), csBox3::MaxY(), csBox3::Min(), csBox3::MinY(), Norm(), Normalize(), operator!=(), operator*(), operator*=(), csBox3::operator*=(), operator+(), operator+(), operator+=(), csBox3::operator+=(), operator-(), operator-=(), operator/=(), operator<(), operator==(), operator>(), operator[](), csBox3::Overlap(), Set(), csBox3::Set(), SquaredNorm(), csBox3::SquaredOriginDist(), csBox3::SquaredOriginMaxDist(), and csBox3::StartBoundingBox().
float csVector3::z |
The Z component of the vector.
Definition at line 36 of file opvector3.h.
Referenced by csBox3::AddBoundingVertex(), csBox3::AddBoundingVertexSmart(), csBox3::Between(), ContinuousTerrain::Collide(), csOPCODECollider::Collide(), csBox3::Contains(), Cross(), csTerrainSegmentCellCollider::csTerrainSegmentCellCollider(), csBox3::Empty(), csBox3::GetCenter(), csBox3::GetConvexOutline(), csTerrainSegmentCellCollider::GetIntersection(), csBox3::GetVisibleSides(), csBox3::In(), Unit::InsideCollideTree(), IsZero(), csBox3::ManhattanDistance(), csBox3::Max(), csBox3::MaxZ(), csBox3::Min(), csBox3::MinZ(), Norm(), Normalize(), operator!=(), operator*(), operator*=(), csBox3::operator*=(), operator+(), operator+(), operator+=(), csBox3::operator+=(), operator-(), operator-=(), operator/=(), operator<(), operator==(), operator>(), operator[](), csBox3::Overlap(), Set(), csBox3::Set(), SquaredNorm(), csBox3::SquaredOriginDist(), csBox3::SquaredOriginMaxDist(), and csBox3::StartBoundingBox().