# cee::Vec3f

class Vec3f

Vector class for a 3D float vector.

Public Functions

Vec3f()

Constructs a null vector.

Vec3f(const Vec3f &other)

Constructs a vector as a copy of other.

Vec3f(float x, float y, float z)

Constructs a vector from an x, y and z coordinate.

Vec3f &operator=(const Vec3f &other)

Assigns other to this vector and returns a reference to this vector.

bool operator==(const Vec3f &rhs) const

Returns true if two vectors are equal, otherwise returns false.

An exact match is required x() == rhs.x(), etc.

bool operator!=(const Vec3f &rhs) const

Returns true if two vectors are not equal, otherwise returns false.

Exact comparison is used (!= between floats)

const Vec3f operator+(const Vec3f &rhs) const

Returns a vector that is this vector added with rhs.

const Vec3f operator-(const Vec3f &rhs) const

Returns a vector that is this vector subtracted with rhs.

const Vec3f operator*(float scalar) const

Returns a vector that is this vector multiplies with scalar.

const Vec3f operator/(float scalar) const

Returns a vector that is this vector divided with scalar.

Vec3f &operator+=(const Vec3f &rhs)

Adds the given rhs vector to this.

Vec3f &operator-=(const Vec3f &rhs)

Subtracts the given rhs vector from this.

Vec3f &operator*=(float scalar)

Multiplies every components of this vector with the given scalar.

Vec3f &operator/=(float scalar)

Divides every components of this vector with the given scalar.

float operator*(const Vec3f &rhs) const

Computes the dot product of this and rhs and return the result (scalar)

Formula:

```S = tx*rx + ty*ry + tz*rz
```

const Vec3f operator^(const Vec3f &rhs) const

Computes the cross product of this and rhs and return the result (vector)

Formula:

```vec = <ty*rz - tz*ry, tz*rx - tx*rz, tx*ry - ty*rx>
```

const float &x() const

X element of the vector.

const float &y() const

Y element of the vector.

const float &z() const

Z element of the vector.

float &x()

X element of the vector.

float &y()

Y element of the vector.

float &z()

Z element of the vector.

void set(float x, float y, float z)

Sets x, y and z value.

void transformPoint(const Mat4d &m)

Transforms this point with the transformation matrix m.

void transformVector(const Mat4d &m)

Transforms this vector with the transformation matrix m.

bool normalize()

Normalizes this vector.

Returns false if the vector is a null vector. Otherwise returns true.

float length() const

Returns the length of this vector.

float angle(const Vec3f &other)

Returns the angle (in radians) between this vector and the other.

Public Static Functions

static float dot(const Vec3f &v1, const Vec3f &v2)

Returns the dot product of v1 and v2.

Formula:

```S = tx*rx + ty*ry + tz*rz
```

static Vec3f cross(const Vec3f &v1, const Vec3f &v2)

Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.