Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_Vector

Vector class
Contained in: global
Derived from: none
Derived by: none
Group: Core (Math)

#include <ClanLib/core.h>

### public function member index:

### Construction:

`` | `CL_Vector` | `(`float` `x` = 0.0, `float` `y` = 0.0, `float` `z` = 0.0, `float` `w` = 1.0)`;
`` | `CL_Vector` | `(`const` `CL_Vector`& `other`)`;

### Attributes:

``float`` | `norm` | `() `const``;
``void`` | `normalize` | `()`;
``float`` | `dot` | `(`const` `CL_Vector`& `v`) `const``;
``float`` | `angle` | `(`const` `CL_Vector`& `v`) `const``;
``CL_Vector`` | `cross` | `(`const` `CL_Vector`& `v`) `const``;
``CL_Vector`` | `rotate` | `(`float` `angle`, `const` `CL_Vector`& `a`) `const``;
``void`` | `round` | `()`;

### Operators:

``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``==` | `(`const` `CL_Vector`& `v`) `const``;
``int`` | `operator``!=` | `(`const` `CL_Vector`& `v`) `const``;
``float`&` | `operator``[]` | `(`int` `n`)`;

## Description:

This class provides basic functions and operators for working with vectors

## Function Member Descriptions:

CL_Vector::CL_Vector - Constructor that initializes a vector
`` `CL_Vector` `(`float` `x` = 0.0, `float` `y` = 0.0, `float` `z` = 0.0, `float` `w` = 1.0)`;

CL_Vector::CL_Vector - Copy Constructor
`` `CL_Vector` `(`const` `CL_Vector`& `other`)`;

> other - vector to copy

CL_Vector::angle - Returns the angle between the current vector and v
``float`` `angle` `(`const` `CL_Vector`& `v`) `const``;

> v - other vector
> Returns - the angle between the two vectors

CL_Vector::cross - Returns the cross product of the current vector and v
``CL_Vector`` `cross` `(`const` `CL_Vector`& `v`) `const``;

> v - other vector
> Returns - the cross product of the two vectors

CL_Vector::dot - Returns the dot product of the current vector and v
``float`` `dot` `(`const` `CL_Vector`& `v`) `const``;

> v - other vector
> Returns - the dot product of the two vectors

CL_Vector::norm - Returns the (euclid) norm of the vector. It only uses the x,y,z ordinates!
``float`` `norm` `() `const``;

> Returns - the euclid norm of the vector (in R^3)

CL_Vector::normalize - Normalizes the vector (not taking into account the w ordinate!)
``void`` `normalize` `()`;

CL_Vector::operator != - Returns false if current vector equals v
``int`` `operator``!=` `(`const` `CL_Vector`& `v`) `const``;

> v - other vector
> Returns - false if v equals the current vector, true otherwise

CL_Vector::operator * - Scalar product (vector * scalar)
``CL_Vector`` `operator``*` `(`float` `s`)`;

> Returns - the scalar product

CL_Vector::operator * = - *= operator (scalar multiplication)
``void`` `operator``* =` `(`float` `s`)`;

CL_Vector::operator + - + operator
``CL_Vector`` `operator``+` `(`const` `CL_Vector`& `v`)`;

CL_Vector::operator += - += operator
``void`` `operator``+=` `(`const` `CL_Vector`& `v`)`;

CL_Vector::operator - - - operator
``CL_Vector`` `operator``-` `(`const` `CL_Vector`& `v`)`;

CL_Vector::operator - - unary - operator
``CL_Vector`` `operator``-` `()`;

CL_Vector::operator -= - -= operator
``void`` `operator``-=` `(`const` `CL_Vector`& `v`)`;

CL_Vector::operator = - assignment operator
``CL_Vector`&` `operator``=` `(`const` `CL_Vector`& `v`)`;

CL_Vector::operator == - Returns true if current vector equals v
``int`` `operator``==` `(`const` `CL_Vector`& `v`) `const``;

> v - other vector
> Returns - true if v equals the current vector, false otherwise

CL_Vector::operator [] - Returns reference to n-th ordinate (0. == x, 1. == y, ...)
``float`&` `operator``[]` `(`int` `n`)`;

> n - number of ordinate (starting with 0)
> Returns - reference to the n-th ordinate

CL_Vector::rotate - Returns the current vector rotated around vector a and angle angle
``CL_Vector`` `rotate` `(`float` `angle`, `const` `CL_Vector`& `a`) `const``;

> angle - angle to rotate
> a - rotation axis
> Returns - the rotated vector

CL_Vector::round - rounds all components
``void`` `round` `()`;

## Variable Member Descriptions:

CL_Vector::w - w coordinate
``float`` ``w`;`

CL_Vector::x - x coordinate
``float`` ``x`;`

CL_Vector::y - y coordinate
``float`` ``y`;`

CL_Vector::z - z coordinate
``float`` ``z`;`