CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

csVector4 Class Reference
[Geometry utilities]

A 4D vector with "float" components. More...

#include <csgeom/vector4.h>

List of all members.

Public Member Functions

void Cross (const csVector4 &v1, const csVector4 &v2)
 Take cross product of two vectors and put result in this vector.
 csVector4 (const csVector3 &v)
 Convert from a three-component vector. w is set to 1.
 csVector4 (const csDVector4 &v)
 Copy from a double-vector.
 csVector4 (const csVector4 &v)
 Copy Constructor.
 csVector4 (float ix, float iy, float iz=0, float iw=1)
 Make a new vector and initialize with the given values.
 csVector4 (float m)
 Make a new initialized vector.
 csVector4 ()
 Make a new vector.
csString Description () const
 Return a textual representation of the vector in the form "x,y,z,w".
void Get (float *v)
 Get the value of this vector.
bool IsZero (float precision=SMALL_EPSILON) const
 Query if the vector is zero.
float Norm () const
 Returns the norm of this vector.
void Normalize ()
 Scale this vector to length = 1.0;.
csVector4operator *= (float f)
 Multiply this vector by a scalar.
csVector4 operator+ () const
 Unary + operator.
csVector4operator+= (const csVector4 &v)
 Add another vector to this vector.
csVector4 operator- () const
 Unary - operator.
csVector4operator-= (const csVector4 &v)
 Subtract another vector from this vector.
csVector4operator/= (float f)
 Divide this vector by a scalar.
float & operator[] (int n)
 Returns n-th component of the vector.
float operator[] (int n) const
 Returns n-th component of the vector.
void Set (float v)
 Set the value of this vector so that all components are the same.
void Set (float const *v)
 Set the value of this vector.
void Set (csVector4 const &v)
 Set the value of this vector.
void Set (float sx, float sy, float sz, float sw)
 Set the value of this vector.
float SquaredNorm () const
 Return the squared norm (magnitude) of this vector.
csVector4 Unit () const
 Returns the unit vector in the direction of this vector.

Static Public Member Functions

static float Norm (const csVector4 &v)
 Returns the norm (magnitude) of a vector.
static csVector4 Unit (const csVector4 &v)
 Normalizes a vector to a unit vector.

Public Attributes

float w
 The W component of the vector.
float x
 The X component of the vector.
float y
 The Y component of the vector.
float z
 The Z component of the vector.

Friends

csVector4 operator * (int f, const csVector4 &v)
 Multiply a vector and a scalar int.
csVector4 operator * (const csVector4 &v, int f)
 Multiply a vector and a scalar int.
csDVector4 operator * (double f, const csVector4 &v)
 Multiply a vector and a scalar double. Upgrade v to csDVector4.
csDVector4 operator * (const csVector4 &v, double f)
 Multiply a vector and a scalar double. Upgrade v to csDVector4.
csVector4 operator * (float f, const csVector4 &v)
 Multiply a vector and a scalar.
csVector4 operator * (const csVector4 &v, float f)
 Multiply a vector and a scalar.
float operator * (const csVector4 &v1, const csVector4 &v2)
 Take the dot product of two vectors.
bool operator!= (const csVector4 &v1, const csVector4 &v2)
 Check if two vectors are not equal.
csVector4 operator% (const csVector4 &v1, const csVector4 &v2)
 Take the cross product of two vectors.
csDVector4 operator+ (const csVector4 &v1, const csDVector4 &v2)
 Add two vectors of differing type, raise the csVector4 to csDVector4.
csDVector4 operator+ (const csDVector4 &v1, const csVector4 &v2)
 Add two vectors of differing type, raise the csVector4 to csDVector4.
csVector4 operator+ (const csVector4 &v1, const csVector4 &v2)
 Add two vectors.
csDVector4 operator- (const csDVector4 &v1, const csVector4 &v2)
 Subtract two vectors of differing type, raise the csVector4 to csDVector4.
csDVector4 operator- (const csVector4 &v1, const csDVector4 &v2)
 Subtract two vectors of differing type, raise the csVector4 to csDVector4.
csVector4 operator- (const csVector4 &v1, const csVector4 &v2)
 Subtract two vectors.
csVector4 operator/ (const csVector4 &v, int f)
 Divide a vector by a scalar int.
csDVector4 operator/ (const csVector4 &v, double f)
 Divide a vector by a scalar double. Upgrade v to csDVector4.
csVector4 operator/ (const csVector4 &v, float f)
 Divide a vector by a scalar.
bool operator< (const csVector4 &v, float f)
 Test if each component of a vector is less than a small epsilon value.
csVector4 operator<< (const csVector4 &v1, const csVector4 &v2)
 Project one vector onto another.
bool operator== (const csVector4 &v1, const csVector4 &v2)
 Check if two vectors are equal.
bool operator> (float f, const csVector4 &v)
 Test if each component of a vector is less than a small epsilon value.
csVector4 operator>> (const csVector4 &v1, const csVector4 &v2)
 Project one vector onto another.


Detailed Description

A 4D vector with "float" components.

Definition at line 226 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.

Definition at line 242 of file vector4.h.

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 249 of file vector4.h.

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 252 of file vector4.h.

csVector4::csVector4 const csVector4 v  )  [inline]
 

Copy Constructor.

Definition at line 256 of file vector4.h.

csVector4::csVector4 const csDVector4 v  ) 
 

Copy from a double-vector.

csVector4::csVector4 const csVector3 v  )  [inline]
 

Convert from a three-component vector. w is set to 1.

Definition at line 262 of file vector4.h.


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 307 of file vector4.h.

References w, x, y, and z.

csString csVector4::Description  )  const
 

Return a textual representation of the vector in the form "x,y,z,w".

void csVector4::Get float *  v  )  [inline]
 

Get the value of this vector.

Definition at line 433 of file vector4.h.

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

Query if the vector is zero.

Definition at line 459 of file vector4.h.

References ABS.

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

Returns the norm (magnitude) of a vector.

Definition at line 450 of file vector4.h.

References Norm().

float csVector4::Norm  )  const
 

Returns the norm of this vector.

Referenced by Norm().

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 406 of file vector4.h.

csVector4 csVector4::operator+  )  const [inline]
 

Unary + operator.

Definition at line 414 of file vector4.h.

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

Add another vector to this vector.

Definition at line 384 of file vector4.h.

References w, x, y, and z.

csVector4 csVector4::operator-  )  const [inline]
 

Unary - operator.

Definition at line 417 of file vector4.h.

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

Subtract another vector from this vector.

Definition at line 395 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 410 of file vector4.h.

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

Returns n-th component of the vector.

Definition at line 380 of file vector4.h.

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

Returns n-th component of the vector.

Definition at line 376 of file vector4.h.

void csVector4::Set float  v  )  [inline]
 

Set the value of this vector so that all components are the same.

Definition at line 430 of file vector4.h.

void csVector4::Set float const *  v  )  [inline]
 

Set the value of this vector.

Definition at line 427 of file vector4.h.

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

Set the value of this vector.

Definition at line 424 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 420 of file vector4.h.

float csVector4::SquaredNorm  )  const [inline]
 

Return the squared norm (magnitude) of this vector.

Definition at line 439 of file vector4.h.

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

Normalizes a vector to a unit vector.

Definition at line 453 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 447 of file vector4.h.

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 336 of file vector4.h.

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

Multiply a vector and a scalar int.

Definition at line 332 of file vector4.h.

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

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

Definition at line 328 of file vector4.h.

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

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

Definition at line 324 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 320 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 316 of file vector4.h.

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

Take the dot product of two vectors.

Definition at line 293 of file vector4.h.

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

Check if two vectors are not equal.

Definition at line 356 of file vector4.h.

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

Take the cross product of two vectors.

Definition at line 297 of file vector4.h.

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

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

Definition at line 276 of file vector4.h.

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

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

Definition at line 272 of file vector4.h.

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

Add two vectors.

Definition at line 268 of file vector4.h.

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

Subtract two vectors of differing type, raise the csVector4 to csDVector4.

Definition at line 288 of file vector4.h.

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

Subtract two vectors of differing type, raise the csVector4 to csDVector4.

Definition at line 284 of file vector4.h.

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

Subtract two vectors.

Definition at line 280 of file vector4.h.

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

Divide a vector by a scalar int.

Definition at line 348 of file vector4.h.

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

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

Definition at line 344 of file vector4.h.

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

Divide a vector by a scalar.

Definition at line 340 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 368 of file vector4.h.

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

Project one vector onto another.

Definition at line 364 of file vector4.h.

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

Check if two vectors are equal.

Definition at line 352 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 372 of file vector4.h.

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

Project one vector onto another.

Definition at line 360 of file vector4.h.


Member Data Documentation

float csVector4::w
 

The W component of the vector.

Definition at line 236 of file vector4.h.

Referenced by Cross(), operator+=(), operator-=(), Set(), and csShaderVariable::SetValue().

float csVector4::x
 

The X component of the vector.

Definition at line 230 of file vector4.h.

Referenced by Cross(), operator+=(), operator-=(), Set(), and csShaderVariable::SetValue().

float csVector4::y
 

The Y component of the vector.

Definition at line 232 of file vector4.h.

Referenced by Cross(), operator+=(), operator-=(), Set(), and csShaderVariable::SetValue().

float csVector4::z
 

The Z component of the vector.

Definition at line 234 of file vector4.h.

Referenced by Cross(), operator+=(), operator-=(), Set(), and csShaderVariable::SetValue().


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