CrystalSpace

Public API Reference

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

csDVector4 Class Reference
[Geometry utilities]

A 3D vector. More...

#include <vector4.h>

List of all members.

Public Methods

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

 csDVector4 (double m)
 Make a new initialized vector. More...

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

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

 csDVector4 (const csVector4 &)
 Conversion from single precision vector to double. More...

 csDVector4 (const csDVector3 &v)
 Conversion from a 3 component vector. set W =0;. More...

void Cross (const csDVector4 &v1, const csDVector4 &v2)
 Take cross product of two vectors and put result in this vector. More...

double operator[] (int n) const
 Returns n-th component of the vector. More...

double & operator[] (int n)
 Returns n-th component of the vector. More...

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

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

csDVector4 & operator *= (double f)
 Multiply this vector by a scalar. More...

csDVector4 & operator/= (double f)
 Divide this vector by a scalar. More...

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

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

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

double Norm () const
 Returns the norm of this vector. More...

double SquaredNorm () const
 Returns the norm of this vector. More...

csDVector4 Unit () const
 Returns the unit vector in the direction of this vector. More...

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


Static Public Methods

double Norm (const csDVector4 &v)
 Returns the norm (magnitude) of a vector. More...

csDVector4 Unit (const csDVector4 &v)
 Normalizes a vector to a unit vector. More...


Public Attributes

double x
 The X component of the vector. More...

double y
 The Y component of the vector. More...

double z
 The Z component of the vector. More...

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


Friends

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

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

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

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

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

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

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

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

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

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

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

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

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


Detailed Description

A 3D vector.

Definition at line 43 of file vector4.h.


Constructor & Destructor Documentation

csDVector4::csDVector4   [inline]
 

Make a new vector.

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

Definition at line 60 of file vector4.h.

Referenced by operator-.

csDVector4::csDVector4 double    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 csDVector4(0)

Definition at line 67 of file vector4.h.

References w, x, y, and z.

csDVector4::csDVector4 double    ix,
double    iy,
double    iz = 0,
double    iw = 1
[inline]
 

Make a new vector and initialize with the given values.

Definition at line 70 of file vector4.h.

References w, x, y, and z.

csDVector4::csDVector4 const csDVector4 &    v [inline]
 

Copy Constructor.

Definition at line 73 of file vector4.h.

References w, x, y, and z.

csDVector4::csDVector4 const csVector4  
 

Conversion from single precision vector to double.

csDVector4::csDVector4 const csDVector3   v [inline]
 

Conversion from a 3 component vector. set W =0;.

Definition at line 79 of file vector4.h.

References w, csDVector3::x, x, csDVector3::y, y, csDVector3::z, and z.


Member Function Documentation

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

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

Definition at line 106 of file vector4.h.

References w, x, y, and z.

double csDVector4::Norm const csDVector4 &    v [inline, static]
 

Returns the norm (magnitude) of a vector.

Definition at line 211 of file vector4.h.

References Norm.

double csDVector4::Norm   const
 

Returns the norm of this vector.

Referenced by Norm, and Unit.

void csDVector4::Normalize  
 

Scale this vector to length = 1.0.

csDVector4& csDVector4::operator *= double    f [inline]
 

Multiply this vector by a scalar.

Definition at line 181 of file vector4.h.

References w, x, y, and z.

csDVector4 csDVector4::operator+   const [inline]
 

Unary + operator.

Definition at line 189 of file vector4.h.

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

Add another vector to this vector.

Definition at line 159 of file vector4.h.

References w, x, y, and z.

csDVector4 csDVector4::operator-   const [inline]
 

Unary - operator.

Definition at line 192 of file vector4.h.

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

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

Subtract another vector from this vector.

Definition at line 170 of file vector4.h.

References w, x, y, and z.

csDVector4& csDVector4::operator/= double    f [inline]
 

Divide this vector by a scalar.

Definition at line 185 of file vector4.h.

References w, x, y, and z.

double& csDVector4::operator[] int    n [inline]
 

Returns n-th component of the vector.

Definition at line 156 of file vector4.h.

References w, x, y, and z.

double csDVector4::operator[] int    n const [inline]
 

Returns n-th component of the vector.

Definition at line 153 of file vector4.h.

References w, x, y, and z.

void csDVector4::Set double    sx,
double    sy,
double    sz,
double    sw
[inline]
 

Set the value of this vector.

Definition at line 195 of file vector4.h.

References w, x, y, and z.

double csDVector4::SquaredNorm   const
 

Returns the norm of this vector.

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

Normalizes a vector to a unit vector.

Definition at line 214 of file vector4.h.

References Unit.

csDVector4 csDVector4::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 208 of file vector4.h.

References Norm.

Referenced by Unit.


Friends And Related Function Documentation

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

Multiply a vector and a scalar.

Definition at line 119 of file vector4.h.

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

Multiply a vector and a scalar.

Definition at line 115 of file vector4.h.

double operator * const csDVector4 &    v1,
const csDVector4 &    v2
[friend]
 

Take the dot product of two vectors.

Definition at line 92 of file vector4.h.

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

Check if two vectors are not equal.

Definition at line 131 of file vector4.h.

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

Take the cross product of two vectors.

Definition at line 96 of file vector4.h.

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

Add two vectors.

Definition at line 83 of file vector4.h.

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

Subtract two vectors.

Definition at line 88 of file vector4.h.

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

Divide a vector by a scalar.

Definition at line 123 of file vector4.h.

bool operator< const csDVector4 &    v,
double    f
[friend]
 

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

Definition at line 145 of file vector4.h.

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

Project one vector onto another.

Definition at line 141 of file vector4.h.

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

Check if two vectors are equal.

Definition at line 127 of file vector4.h.

bool operator> double    f,
const csDVector4 &    v
[friend]
 

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

Definition at line 149 of file vector4.h.

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

Project one vector onto another.

Definition at line 136 of file vector4.h.


Member Data Documentation

double csDVector4::w
 

The W component of the vector.

Definition at line 53 of file vector4.h.

Referenced by Cross, csDVector4, operator *=, operator+=, operator-, operator-=, operator/=, operator[], and Set.

double csDVector4::x
 

The X component of the vector.

Definition at line 47 of file vector4.h.

Referenced by Cross, csDVector4, operator *=, operator+=, operator-, operator-=, operator/=, operator[], and Set.

double csDVector4::y
 

The Y component of the vector.

Definition at line 49 of file vector4.h.

Referenced by Cross, csDVector4, operator *=, operator+=, operator-, operator-=, operator/=, operator[], and Set.

double csDVector4::z
 

The Z component of the vector.

Definition at line 51 of file vector4.h.

Referenced by Cross, csDVector4, operator *=, operator+=, operator-, operator-=, operator/=, operator[], and Set.


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