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 with "float" components. More...

#include <vector4.h>

List of all members.

Public Methods

 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.

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

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

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

csVector4 & operator/= (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 (const csVector4 &v)
 Set 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 Methods

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 227 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 243 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 250 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 253 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 303 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 445 of file vector4.h.

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

Returns the norm (magnitude) of a vector.

Definition at line 436 of file vector4.h.

References Norm().

float csVector4::Norm  
 

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

csVector4 csVector4::operator+   const [inline]
 

Unary + operator.

Definition at line 410 of file vector4.h.

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

Add another vector to this vector.

Definition at line 380 of file vector4.h.

References w, x, y, and z.

csVector4 csVector4::operator-   const [inline]
 

Unary - operator.

Definition at line 413 of file vector4.h.

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

Subtract another vector from this vector.

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

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

Returns n-th component of the vector.

Definition at line 376 of file vector4.h.

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

Returns n-th component of the vector.

Definition at line 372 of file vector4.h.

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

Set the value of this vector.

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

Referenced by csShaderVariable::SetValue().

float csVector4::SquaredNorm   const [inline]
 

Return the squared norm (magnitude) of this vector.

Definition at line 425 of file vector4.h.

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

Normalizes a vector to a unit vector.

Definition at line 439 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 433 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 332 of file vector4.h.

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

Multiply a vector and a scalar int.

Definition at line 328 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 324 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 320 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 316 of file vector4.h.

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

Multiply a vector and a scalar.

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

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

Divide a vector by a scalar.

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

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

Check if two vectors are equal.

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

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

Project one vector onto another.

Definition at line 356 of file vector4.h.


Member Data Documentation

float csVector4::w
 

The W component of the vector.

Definition at line 237 of file vector4.h.

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

float csVector4::x
 

The X component of the vector.

Definition at line 231 of file vector4.h.

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

float csVector4::y
 

The Y component of the vector.

Definition at line 233 of file vector4.h.

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

float csVector4::z
 

The Z component of the vector.

Definition at line 235 of file vector4.h.

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


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