---
name: "CL_Vector"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_Vector"
---

# 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 \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. 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.
