CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | 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

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

Static Public Member Functions

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

Public Attributes

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

Friends

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


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.

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

References w, x, y, and z.

csVector4::csVector4 const csVector4 v  )  [inline]
 

Copy Constructor.

Definition at line 256 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 a three-component vector. w is set to 1.

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

References w, x, y, and z.

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

Get the value of this vector.

Definition at line 430 of file vector4.h.

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

Query if the vector is zero.

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

References w, x, y, and z.

csVector4 csVector4::operator+  )  const [inline]
 

Unary + operator.

Definition at line 411 of file vector4.h.

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

Add another vector to this vector.

Definition at line 381 of file vector4.h.

References w, x, y, and z.

csVector4 csVector4::operator-  )  const [inline]
 

Unary - operator.

Definition at line 414 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 392 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 407 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 377 of file vector4.h.

References x, y, and z.

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

Returns n-th component of the vector.

Definition at line 373 of file vector4.h.

References x, y, and z.

void csVector4::Set float  v  )  [inline]
 

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

Definition at line 427 of file vector4.h.

References w, x, y, and z.

void csVector4::Set float 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 csVector4 const &  v  )  [inline]
 

Set the value of this vector.

Definition at line 421 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 417 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 436 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 450 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 444 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 333 of file vector4.h.

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

Multiply a vector and a scalar int.

Definition at line 329 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 325 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 321 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 317 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 313 of file vector4.h.

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

Take the dot product of two vectors.

Definition at line 290 of file vector4.h.

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

Check if two vectors are not equal.

Definition at line 353 of file vector4.h.

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

Take the cross product of two vectors.

Definition at line 294 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 273 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 269 of file vector4.h.

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

Add two vectors.

Definition at line 265 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 285 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 281 of file vector4.h.

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

Subtract two vectors.

Definition at line 277 of file vector4.h.

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

Divide a vector by a scalar int.

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

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

Divide a vector by a scalar.

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

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

Project one vector onto another.

Definition at line 361 of file vector4.h.

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

Check if two vectors are equal.

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

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

Project one vector onto another.

Definition at line 357 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(), csVector4(), IsZero(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), Set(), csShaderVariable::SetValue(), and SquaredNorm().

float csVector4::x
 

The X component of the vector.

Definition at line 230 of file vector4.h.

Referenced by Cross(), csVector4(), IsZero(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), Set(), csShaderVariable::SetValue(), and SquaredNorm().

float csVector4::y
 

The Y component of the vector.

Definition at line 232 of file vector4.h.

Referenced by Cross(), csVector4(), IsZero(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), Set(), csShaderVariable::SetValue(), and SquaredNorm().

float csVector4::z
 

The Z component of the vector.

Definition at line 234 of file vector4.h.

Referenced by Cross(), csVector4(), IsZero(), operator *=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), Set(), csShaderVariable::SetValue(), and SquaredNorm().


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