CrystalSpace

Public API Reference

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

csVector4 Class Reference
[Geometry utilities]

A 4D vector. More...

#include <vector4.h>

List of all members.

Public Methods

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

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

 csVector4 (float ix, float iy, float iz=0, float iw=1)
 Make a new vector and initialize with the given values. More...

 csVector4 (const csVector4 &v)
 Copy Constructor. More...

 csVector4 (const csDVector4 &v)
 Copy from a double-vector. More...

 csVector4 (const csVector3 &v)
 Convert from csVector3. Set w = 1. More...

void Cross (const csVector4 &v1, const csVector4 &v2)
 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...

csVector4 & operator+= (const csVector4 &v)
 Add another vector to this vector. More...

csVector4 & operator-= (const csVector4 &v)
 Subtract another vector from this vector. More...

csVector4 & operator *= (float f)
 Multiply this vector by a scalar. More...

csVector4 & operator/= (float f)
 Divide this vector by a scalar. More...

csVector4 operator+ () const
 Unary + operator. More...

csVector4 operator- () const
 Unary - operator. More...

void Set (float sx, float sy, float sz, float sw)
 Set the value of this vector. More...

void Set (const csVector4 &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...

csVector4 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 csVector4 &v)
 Returns the norm (magnitude) of a vector. More...

csVector4 Unit (const csVector4 &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...

float w
 The W component of the vector. More...


Friends

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

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

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

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

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

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

float operator * (const csVector4 &v1, const csVector4 &v2)
 Take the dot product of two vectors. More...

csVector4 operator% (const csVector4 &v1, const csVector4 &v2)
 Take the cross product of two vectors. More...

csVector4 operator * (const csVector4 &v, float f)
 Multiply a vector and a scalar. More...

csVector4 operator * (float f, const csVector4 &v)
 Multiply a vector and a scalar. More...

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

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

csVector4 operator * (const csVector4 &v, int f)
 Multiply a vector and a scalar int. More...

csVector4 operator * (int f, const csVector4 &v)
 Multiply a vector and a scalar int. More...

csVector4 operator/ (const csVector4 &v, float f)
 Divide a vector by a scalar. More...

csDVector4 operator/ (const csVector4 &v, double f)
 Divide a vector by a scalar double. Upgrade v to DVector. More...

csVector4 operator/ (const csVector4 &v, int f)
 Divide a vector by a scalar int. More...

bool operator== (const csVector4 &v1, const csVector4 &v2)
 Check if two vectors are equal. More...

bool operator!= (const csVector4 &v1, const csVector4 &v2)
 Check if two vectors are not equal. More...

csVector4 operator>> (const csVector4 &v1, const csVector4 &v2)
 Project one vector onto another. More...

csVector4 operator<< (const csVector4 &v1, const csVector4 &v2)
 Project one vector onto another. More...

bool operator< (const csVector4 &v, float f)
 Test if each component of a vector is less than a small epsilon value. More...

bool operator> (float f, const csVector4 &v)
 Test if each component of a vector is less than a small epsilon value. More...


Detailed Description

A 4D vector.

Definition at line 224 of file vector4.h.


Constructor & Destructor Documentation

csVector4::csVector4   [inline]
 

Make a new vector.

The vector is not initialized. This makes the code slightly faster as csVector4 objects are used a lot.

Definition at line 241 of file vector4.h.

Referenced by operator-.

csVector4::csVector4 float    m [inline]
 

Make a new initialized vector.

Creates a new vector and initializes it to m*<1,1,1,1>. To create a vector initialized to the zero vector, use csVector4(0)

Definition at line 248 of file vector4.h.

References w, x, y, and z.

csVector4::csVector4 float    ix,
float    iy,
float    iz = 0,
float    iw = 1
[inline]
 

Make a new vector and initialize with the given values.

Definition at line 251 of file vector4.h.

References w, x, y, and z.

csVector4::csVector4 const csVector4 &    v [inline]
 

Copy Constructor.

Definition at line 254 of file vector4.h.

References w, x, y, and z.

csVector4::csVector4 const csDVector4   v
 

Copy from a double-vector.

csVector4::csVector4 const csVector3   v [inline]
 

Convert from csVector3. Set w = 1.

Definition at line 260 of file vector4.h.

References w, x, y, and z.


Member Function Documentation

void csVector4::Cross const csVector4 &    v1,
const csVector4 &    v2
[inline]
 

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

Definition at line 301 of file vector4.h.

References w, x, y, and z.

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

Query if the vector is zero.

Definition at line 441 of file vector4.h.

References w, x, y, and z.

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

Returns the norm (magnitude) of a vector.

Definition at line 432 of file vector4.h.

References Norm.

float csVector4::Norm   const
 

Returns the norm of this vector.

Referenced by Norm, and Unit.

void csVector4::Normalize  
 

Scale this vector to length = 1.0;.

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

Multiply this vector by a scalar.

Definition at line 398 of file vector4.h.

References w, x, y, and z.

csVector4 csVector4::operator+   const [inline]
 

Unary + operator.

Definition at line 406 of file vector4.h.

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

Add another vector to this vector.

Definition at line 376 of file vector4.h.

References w, x, y, and z.

csVector4 csVector4::operator-   const [inline]
 

Unary - operator.

Definition at line 409 of file vector4.h.

References csVector4, w, x, y, and z.

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

Subtract another vector from this vector.

Definition at line 387 of file vector4.h.

References w, x, y, and z.

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

Divide this vector by a scalar.

Definition at line 402 of file vector4.h.

References w, x, y, and z.

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

Returns n-th component of the vector.

Definition at line 373 of file vector4.h.

References w, x, y, and z.

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

Returns n-th component of the vector.

Definition at line 370 of file vector4.h.

References w, x, y, and z.

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

Set the value of this vector.

Definition at line 415 of file vector4.h.

References w, x, y, and z.

void csVector4::Set float    sx,
float    sy,
float    sz,
float    sw
[inline]
 

Set the value of this vector.

Definition at line 412 of file vector4.h.

References w, x, y, and z.

float csVector4::SquaredNorm   const [inline]
 

Return the squared norm (magnitude) of this vector.

Definition at line 421 of file vector4.h.

References w, x, y, and z.

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

Normalizes a vector to a unit vector.

Definition at line 435 of file vector4.h.

References Unit.

csVector4 csVector4::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 429 of file vector4.h.

References Norm.

Referenced by Unit.


Friends And Related Function Documentation

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

Multiply a vector and a scalar int.

Definition at line 330 of file vector4.h.

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

Multiply a vector and a scalar int.

Definition at line 326 of file vector4.h.

csDVector4 operator * double    f,
const csVector4 &    v
[friend]
 

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

Definition at line 322 of file vector4.h.

csDVector4 operator * const csVector4 &    v,
double    f
[friend]
 

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

Definition at line 318 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 314 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 310 of file vector4.h.

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

Take the dot product of two vectors.

Definition at line 288 of file vector4.h.

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

Check if two vectors are not equal.

Definition at line 350 of file vector4.h.

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

Take the cross product of two vectors.

Definition at line 292 of file vector4.h.

csDVector4 operator+ const csVector4 &    v1,
const csDVector4   v2
[friend]
 

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

Definition at line 271 of file vector4.h.

csDVector4 operator+ const csDVector4   v1,
const csVector4 &    v2
[friend]
 

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

Definition at line 267 of file vector4.h.

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

Add two vectors.

Definition at line 263 of file vector4.h.

csDVector4 operator- const csDVector4   v1,
const csVector4 &    v2
[friend]
 

Subtract two vectors of differing type, cast to double.

Definition at line 283 of file vector4.h.

csDVector4 operator- const csVector4 &    v1,
const csDVector4   v2
[friend]
 

Subtract two vectors of differing type, cast to double.

Definition at line 279 of file vector4.h.

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

Subtract two vectors.

Definition at line 275 of file vector4.h.

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

Divide a vector by a scalar int.

Definition at line 342 of file vector4.h.

csDVector4 operator/ const csVector4 &    v,
double    f
[friend]
 

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

Definition at line 338 of file vector4.h.

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

Divide a vector by a scalar.

Definition at line 334 of file vector4.h.

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

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

Definition at line 362 of file vector4.h.

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

Project one vector onto another.

Definition at line 358 of file vector4.h.

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

Check if two vectors are equal.

Definition at line 346 of file vector4.h.

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

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

Definition at line 366 of file vector4.h.

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

Project one vector onto another.

Definition at line 354 of file vector4.h.


Member Data Documentation

float csVector4::w
 

The W component of the vector.

Definition at line 234 of file vector4.h.

Referenced by Cross, csVector4, IsZero, operator *=, operator+=, operator-, operator-=, operator/=, operator[], Set, and SquaredNorm.

float csVector4::x
 

The X component of the vector.

Definition at line 228 of file vector4.h.

Referenced by Cross, csVector4, IsZero, operator *=, operator+=, operator-, operator-=, operator/=, operator[], Set, and SquaredNorm.

float csVector4::y
 

The Y component of the vector.

Definition at line 230 of file vector4.h.

Referenced by Cross, csVector4, IsZero, operator *=, operator+=, operator-, operator-=, operator/=, operator[], Set, and SquaredNorm.

float csVector4::z
 

The Z component of the vector.

Definition at line 232 of file vector4.h.

Referenced by Cross, csVector4, IsZero, operator *=, operator+=, operator-, operator-=, operator/=, operator[], Set, and SquaredNorm.


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