CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csVector3 Class Reference
[Geometry utilities]

A 3D vector. More...

#include <vector3.h>

List of all members.

Public Methods

 csVector3 ()
 Make a new vector. More...

 csVector3 (float m)
 Make a new initialized vector. More...

 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 csDVector3 &)
 Conversion from double precision vector to single. More...

void Cross (const csVector3 &px, const csVector3 &py)
 Take cross product of two vectors and put result in this vector. More...

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
 Returns the unit vector in the direction of this vector. More...

void Normalize ()
 Scale this vector to length = 1.0;. More...

bool IsZero (float precision=SMALL_EPSILON) const
 Query if the vector is zero. More...


Static Public Methods

float Norm (const csVector3 &v)
 Returns the norm (magnitude) of a vector. More...

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

csVector3 operator+ (const csVector3 &v1, const csVector3 &v2)
 Add two vectors. More...

csDVector3 operator+ (const csDVector3 &v1, const csVector3 &v2)
 Add two vectors of differing type, raise the csVector3 to DVector3. More...

csDVector3 operator+ (const csVector3 &v1, const csDVector3 &v2)
 Add two vectors of differing type, raise the csVector3 to DVector3. More...

csVector3 operator- (const csVector3 &v1, const csVector3 &v2)
 Subtract two vectors. More...

csDVector3 operator- (const csVector3 &v1, const csDVector3 &v2)
 Subtract two vectors of differing type, cast to double. More...

csDVector3 operator- (const csDVector3 &v1, const csVector3 &v2)
 Subtract two vectors of differing type, cast to double. More...

float operator * (const csVector3 &v1, const csVector3 &v2)
 Take the dot product of two vectors. 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...

csDVector3 operator * (const csVector3 &v, double f)
 Multiply a vector and a scalar double. Upgrade v to DVector. More...

csDVector3 operator * (double f, const csVector3 &v)
 Multiply a vector and a scalar double. Upgrade v to DVector. 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...

csDVector3 operator/ (const csVector3 &v, double f)
 Divide a vector by a scalar double. Upgrade v to DVector. 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...


Detailed Description

A 3D vector.

Definition at line 38 of file vector3.h.


Constructor & Destructor Documentation

csVector3::csVector3   [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 53 of file vector3.h.

Referenced by operator-.

csVector3::csVector3 float    m [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 60 of file vector3.h.

References x, y, and z.

csVector3::csVector3 float    ix,
float    iy,
float    iz = 0
[inline]
 

Make a new vector and initialize with the given values.

Definition at line 63 of file vector3.h.

References x, y, and z.

csVector3::csVector3 const csVector3 &    v [inline]
 

Copy Constructor.

Definition at line 66 of file vector3.h.

References x, y, and z.

csVector3::csVector3 const csDVector3  
 

Conversion from double precision vector to single.


Member Function Documentation

void csVector3::Cross const csVector3 &    px,
const csVector3 &    py
[inline]
 

Take cross product of two vectors and put result in this vector.

Definition at line 108 of file vector3.h.

References x, y, and z.

bool csVector3::IsZero float    precision = SMALL_EPSILON const [inline]
 

Query if the vector is zero.

Definition at line 245 of file vector3.h.

References x, y, and z.

float csVector3::Norm const csVector3 &    v [inline, static]
 

Returns the norm (magnitude) of a vector.

Definition at line 236 of file vector3.h.

References Norm.

float csVector3::Norm   const
 

Returns the norm of this vector.

Referenced by Norm, csPlane3::Normalize, and Unit.

void csVector3::Normalize  
 

Scale this vector to length = 1.0;.

csVector3& csVector3::operator *= float    f [inline]
 

Multiply this vector by a scalar.

Definition at line 202 of file vector3.h.

References x, y, and z.

csVector3 csVector3::operator+   const [inline]
 

Unary + operator.

Definition at line 210 of file vector3.h.

csVector3& csVector3::operator+= const csVector3 &    v [inline]
 

Add another vector to this vector.

Definition at line 182 of file vector3.h.

References x, y, and z.

csVector3 csVector3::operator-   const [inline]
 

Unary - operator.

Definition at line 213 of file vector3.h.

References csVector3, x, y, and z.

csVector3& csVector3::operator-= const csVector3 &    v [inline]
 

Subtract another vector from this vector.

Definition at line 192 of file vector3.h.

References x, y, and z.

csVector3& csVector3::operator/= float    f [inline]
 

Divide this vector by a scalar.

Definition at line 206 of file vector3.h.

References x, y, and z.

float& csVector3::operator[] int    n [inline]
 

Returns n-th component of the vector.

Definition at line 179 of file vector3.h.

References x, y, and z.

float csVector3::operator[] int    n const [inline]
 

Returns n-th component of the vector.

Definition at line 176 of file vector3.h.

References x, y, and z.

void csVector3::Set const csVector3 &    v [inline]
 

Set the value of this vector.

Definition at line 219 of file vector3.h.

References x, y, and z.

void csVector3::Set float    sx,
float    sy,
float    sz
[inline]
 

Set the value of this vector.

Definition at line 216 of file vector3.h.

References x, y, and z.

Referenced by csSphere::csSphere.

float csVector3::SquaredNorm   const [inline]
 

Return the squared norm (magnitude) of this vector.

Definition at line 225 of file vector3.h.

References x, y, and z.

csVector3 csVector3::Unit const csVector3 &    v [inline, static]
 

Normalizes a vector to a unit vector.

Definition at line 239 of file vector3.h.

References Unit.

csVector3 csVector3::Unit   const [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 233 of file vector3.h.

References Norm.

Referenced by Unit.


Friends And Related Function Documentation

csVector3 operator * int    f,
const csVector3 &    v
[friend]
 

Multiply a vector and a scalar int.

Definition at line 136 of file vector3.h.

csVector3 operator * const csVector3 &    v,
int    f
[friend]
 

Multiply a vector and a scalar int.

Definition at line 132 of file vector3.h.

csDVector3 operator * double    f,
const csVector3 &    v
[friend]
 

Multiply a vector and a scalar double. Upgrade v to DVector.

Definition at line 128 of file vector3.h.

csDVector3 operator * const csVector3 &    v,
double    f
[friend]
 

Multiply a vector and a scalar double. Upgrade v to DVector.

Definition at line 124 of file vector3.h.

csVector3 operator * float    f,
const csVector3 &    v
[friend]
 

Multiply a vector and a scalar.

Definition at line 120 of file vector3.h.

csVector3 operator * const csVector3 &    v,
float    f
[friend]
 

Multiply a vector and a scalar.

Definition at line 116 of file vector3.h.

float operator * const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Take the dot product of two vectors.

Definition at line 96 of file vector3.h.

bool operator!= const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Check if two vectors are not equal.

Definition at line 156 of file vector3.h.

csVector3 operator% const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Take the cross product of two vectors.

Definition at line 100 of file vector3.h.

csDVector3 operator+ const csVector3 &    v1,
const csDVector3   v2
[friend]
 

Add two vectors of differing type, raise the csVector3 to DVector3.

Definition at line 80 of file vector3.h.

csDVector3 operator+ const csDVector3   v1,
const csVector3 &    v2
[friend]
 

Add two vectors of differing type, raise the csVector3 to DVector3.

Definition at line 76 of file vector3.h.

csVector3 operator+ const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Add two vectors.

Definition at line 72 of file vector3.h.

csDVector3 operator- const csDVector3   v1,
const csVector3 &    v2
[friend]
 

Subtract two vectors of differing type, cast to double.

Definition at line 92 of file vector3.h.

csDVector3 operator- const csVector3 &    v1,
const csDVector3   v2
[friend]
 

Subtract two vectors of differing type, cast to double.

Definition at line 88 of file vector3.h.

csVector3 operator- const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Subtract two vectors.

Definition at line 84 of file vector3.h.

csVector3 operator/ const csVector3 &    v,
int    f
[friend]
 

Divide a vector by a scalar int.

Definition at line 148 of file vector3.h.

csDVector3 operator/ const csVector3 &    v,
double    f
[friend]
 

Divide a vector by a scalar double. Upgrade v to DVector.

Definition at line 144 of file vector3.h.

csVector3 operator/ const csVector3 &    v,
float    f
[friend]
 

Divide a vector by a scalar.

Definition at line 140 of file vector3.h.

bool operator< const csVector3 &    v,
float    f
[friend]
 

Test if each component of a vector is less than a small epsilon value.

Definition at line 168 of file vector3.h.

csVector3 operator<< const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Project one vector onto another.

Definition at line 164 of file vector3.h.

bool operator== const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Check if two vectors are equal.

Definition at line 152 of file vector3.h.

bool operator> float    f,
const csVector3 &    v
[friend]
 

Test if each component of a vector is less than a small epsilon value.

Definition at line 172 of file vector3.h.

csVector3 operator>> const csVector3 &    v1,
const csVector3 &    v2
[friend]
 

Project one vector onto another.

Definition at line 160 of file vector3.h.


Member Data Documentation

float csVector3::x
 

The X component of the vector.

Definition at line 42 of file vector3.h.

Referenced by csPlane3::A, csBox3::AddBoundingVertex, csBox3::AddBoundingVertexSmart, csPoly3D::AddVertex, csVector3Array::AddVertexSmart, csMath3::Area3, csPlane3::Classify, csBox3::Contains, Cross, csEffectVector4::csEffectVector4, csQuaternion::csQuaternion, csVector3, csBox3::Empty, csPath::GetForwardVector, csPath::GetInterpolatedForward, csPath::GetInterpolatedPosition, csPath::GetInterpolatedUp, csPath::GetPositionVector, csPath::GetUpVector, csBox3::In, csCamera::InvPerspective, csTransform::IsIdentity, IsZero, csBox3::Max, csBox3::Min, operator *=, operator+=, operator-, operator-=, operator/=, operator[], csBox3::Overlap, csCamera::Perspective, csSquaredDist::PointPoint, csQuaternion::PrepRotation, Set, csPlane3::Set, csBox3::Set, csPath::SetForwardVector, csBox3::SetMax, csBox3::SetMin, csMath3::SetMinMax, csPath::SetPositionVector, csPath::SetUpVector, SquaredNorm, csBox3::StartBoundingBox, and csMath3::WhichSide3D.

float csVector3::y
 

The Y component of the vector.

Definition at line 44 of file vector3.h.

Referenced by csBox3::AddBoundingVertex, csBox3::AddBoundingVertexSmart, csPoly3D::AddVertex, csVector3Array::AddVertexSmart, csMath3::Area3, csPlane3::B, csPlane3::Classify, csBox3::Contains, Cross, csEffectVector4::csEffectVector4, csQuaternion::csQuaternion, csVector3, csBox3::Empty, csPath::GetForwardVector, csPath::GetInterpolatedForward, csPath::GetInterpolatedPosition, csPath::GetInterpolatedUp, csPath::GetPositionVector, csPath::GetUpVector, csBox3::In, csCamera::InvPerspective, csTransform::IsIdentity, IsZero, csBox3::Max, csBox3::Min, operator *=, operator+=, operator-, operator-=, operator/=, operator[], csBox3::Overlap, csCamera::Perspective, csSquaredDist::PointPoint, csQuaternion::PrepRotation, Set, csPlane3::Set, csBox3::Set, csPath::SetForwardVector, csBox3::SetMax, csBox3::SetMin, csMath3::SetMinMax, csPath::SetPositionVector, csPath::SetUpVector, SquaredNorm, csBox3::StartBoundingBox, and csMath3::WhichSide3D.

float csVector3::z
 

The Z component of the vector.

Definition at line 46 of file vector3.h.

Referenced by csBox3::AddBoundingVertex, csBox3::AddBoundingVertexSmart, csPoly3D::AddVertex, csVector3Array::AddVertexSmart, csMath3::Area3, csPlane3::C, csPlane3::Classify, csBox3::Contains, Cross, csEffectVector4::csEffectVector4, csQuaternion::csQuaternion, csVector3, csBox3::Empty, csPath::GetForwardVector, csPath::GetInterpolatedForward, csPath::GetInterpolatedPosition, csPath::GetInterpolatedUp, csPath::GetPositionVector, csPath::GetUpVector, csBox3::In, csCamera::InvPerspective, csTransform::IsIdentity, IsZero, csBox3::Max, csBox3::Min, operator *=, operator+=, operator-, operator-=, operator/=, operator[], csBox3::Overlap, csCamera::Perspective, csSquaredDist::PointPoint, csQuaternion::PrepRotation, Set, csPlane3::Set, csBox3::Set, csPath::SetForwardVector, csBox3::SetMax, csBox3::SetMin, csMath3::SetMinMax, csPath::SetPositionVector, csPath::SetUpVector, SquaredNorm, csBox3::StartBoundingBox, and csMath3::WhichSide3D.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.14