GLOW API version 1.0 reference

Back to
Table of contents


class Vec3f

General information

type: class
inherits: (none)
module: glowVectorAlgebra

Vec3f represents a 3-vector of floats. It is used internally by the 3D view transform classes.

Most GLOW programs will not need to use Vec3f directly; however, it may be useful for customizing or manipulating the 3D view transform components.

Methods

Constructors

Vec3f(void)

Creates a new vector with the value set to the origin (0,0,0).

Vec3f(GLfloat xval, GLfloat yval, GLfloat zval)

Creates a new vector with the given coordinates.

Vec3f(const GLfloat* vals)

Creates a new vector, copying the given array of coordinates.

Vec3f(const Vec3f& v)

Copy constructor.

Setters

void Set(GLfloat xval, GLfloat yval, GLfloat zval)

Sets the vector to the specified coordinates.

void Set(const GLfloat* vals)

Sets the vector to the specified array of coordinates.

Vec3f& operator=(const Vec3f& v)

Copies the given vector.

Vec3f& operator=(const GLfloat* vals)

Sets the vector to the specified array of coordinates.

Member access

GLfloat GetX(void) const

GLfloat GetY(void) const

GLfloat GetZ(void) const

void SetX(GLfloat val)

void SetY(GLfloat val)

void SetZ(GLfloat val)

GLfloat& X(void)

GLfloat X(void) const

GLfloat& Y(void)

GLfloat Y(void) const

GLfloat& Z(void)

GLfloat Z(void) const

Indexed member access
You can access members by index. index 0 is the x-coordinate, and index 2 is the z-coordinate. Specifying an index outside those bounds will raise an assertion.

GLfloat GetVal(std::ptrdiff_t i) const

void SetVal(std::ptrdiff_t i, GLfloat val)

GLfloat& operator[](std::ptrdiff_t i)

GLfloat operator[](std::ptrdiff_t i) const

Misc access

void SetZero(void)

Sets the vector to the origin (0,0,0).

bool IsZero(void) const

Is the vector set to the origin (0,0,0)?

operator const GLfloat*(void) const

You can cast a Vec3f directly to a const GLfloat*. This lets you do things like glVertex3fv(myVec3f);.

Special operations

void Negate(void)

Negates the vector.

GLfloat Norm(void) const

Returns the norm of the vector.

GLfloat NormSquared(void) const

Returns the square of the norm of the vector. This is faster than Norm()*Norm().

GLfloat Normalize(void)

Normalizes the vector in place.

Quatf Normalized(void) const

Returns a normalized version of the vector, but leaves the original untouched.

Arithmetic operations
Vec3f provides a full set of arithmetic operations on 3-vectors.

Vec3f == Vec3f ---> bool
vector equality
Vec3f != Vec3f ---> bool
vector inequality

- Vec3f ---> Vec3f
vector negation

Vec3f * GLfloat ---> Vec3f
scalar multiplication
GLfloat * Vec3f ---> Vec3f
scalar multiplication
Vec3f / GLfloat ---> Vec3f
scalar division
Vec3f *= GLfloat
in-place scalar multiplication
Vec3f /= GLfloat
in-place scalar division

Vec3f + Vec3f ---> Vec3f
vector addition
Vec3f - Vec3f ---> Vec3f
vector subtraction
Vec3f * Vec3f ---> GLfloat
dot product
Vec3f % Vec3f ---> Vec3f
cross product
Vec3f += Vec3f
in-place vector addition
Vec3f -= Vec3f
in-place vector subtraction
Vec3f %= Vec3f
in-place cross product


Back to
Table of contents


The GLOW Toolkit