Reference

CL_Vector(3)

Vector class

NAME

CL_Vector - Vector class

DESCRIPTION

This class provides basic functions and operators for working with vectors

CLASS MEMBERS

float x, y, z, w
CL_Vector(
float x = 0.0,
float y = 0.0,
float z = 0.0,
float w = 1.0)

CL_Vector(
const CL_Vector &other)

float norm()
void normalize()
float dot(
const CL_Vector& v)

float angle(
const CL_Vector& v)

CL_Vector cross(
const CL_Vector& v)

CL_Vector rotate(
float angle,
const CL_Vector& a)

void round()
CL_Vector operator * (
float s)

void operator +=(
const CL_Vector& v)

void operator -=(
const CL_Vector& v)

void operator *=(
float s)

CL_Vector operator + (
const CL_Vector& v)

CL_Vector operator - (
const CL_Vector& v)

CL_Vector operator - ()
CL_Vector& operator = (
const CL_Vector& v)

int operator ==(
CL_Vector& v)

int operator !=(
CL_Vector& v)

float& operator [](
int n)

MEMBERS WITH DESCRIPTIONS

float x, y, z, w
Description:

CL_Vector(
float x = 0.0,
float y = 0.0,
float z = 0.0,
float w = 1.0)

Description:

Constructor that initializes a vector

CL_Vector(
const CL_Vector &other)

Parameters:
other - vector to copy

Description:

Copy Constructor

float norm()
Description:

Returns the (euclid) norm of the vector. It only uses the x,y,z ordinates! not using w component

Return value:

the euclid norm of the vector (in R^3)

void normalize()
Description:

Normalizes the vector (not taking into account the w ordinate!) not using w component

float dot(
const CL_Vector& v)

Parameters:
v - other vector 

Description:

Returns the dot product of the current vector and v

Return value:

the dot product of the two vectors

float angle(
const CL_Vector& v)

Parameters:
v - other vector 

Description:

Returns the angle between the current vector and v

Return value:

the angle between the two vectors

CL_Vector cross(
const CL_Vector& v)

Parameters:
v - other vector 

Description:

Returns the cross product of the current vector and v

Return value:

the cross product of the two vectors

CL_Vector rotate(
float angle,
const CL_Vector& a)

Parameters:
angle - angle to rotate
a - rotation axis

Description:

Returns the current vector rotated around vector a and angle angle

Return value:

the rotated vector

void round()
Description:

rounds all components

CL_Vector operator * (
float s)

Description:

Scalar product (vector * scalar)

Return value:

the scalar product

void operator +=(
const CL_Vector& v)

Description:

+= operator

void operator -=(
const CL_Vector& v)

Description:

-= operator

void operator *=(
float s)

Description:

*= operator (scalar multiplication)

CL_Vector operator + (
const CL_Vector& v)

Description:

+ operator

CL_Vector operator - (
const CL_Vector& v)

Description:

- operator

CL_Vector operator - ()
Description:

unary - operator

CL_Vector& operator = (
const CL_Vector& v)

Description:

assignment operator

int operator ==(
CL_Vector& v)

Parameters:
v - other vector

Description:

Returns true if current vector equals v

Return value:

true if v equals the current vector, false otherwise

int operator !=(
CL_Vector& v)

Parameters:
v - other vector

Description:

Returns false if current vector equals v

Return value:

false if v equals the current vector, true otherwise

float& operator [](
int n)

Parameters:
n - number of ordinate (starting with 0)

Description:

Returns reference to n-th ordinate (0. == x, 1. == y, ...)

Return value:

reference to the n-th ordinate

SEE ALSO

All ClanLib API classes can be found in clanlib (3).

AUTHORS

Originally written by Magnus Norddahl <[email protected]> and Martin Starch <[email protected]>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at http://somewhere.in.the.world.org).

See clanlib (3) to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.