vec4 class by value built-in

Four-dimensional vector with floating-point components

Constructors

vec4(const vec4&in)
Creates a copy of another vector
vec4(const vec4i&in)
Creates a vector from an integer vector
vec4(float, float, float, float)
Creates a vector from X, Y, Z and W components
vec4(int, int, int, int)
Creates a vector from integer X, Y, Z and W components

Functions

void normalize()
Scales the vector in place to a length of 1
vec4 normalized() const
Returns a copy of the vector scaled to a length of 1

Operators

vec4 opAdd(const vec4&in) const +
Adds two vectors
vec4& opAddAssign(const vec4&in) +=
Adds another vector in place
vec4& opAssign(const vec4&in) =
Copies another vector
vec4 opDiv(float) const /
Divides every component by a number
vec4 opDiv(const vec4&in) const /
Divides the vectors component by component
vec4& opDivAssign(float) /=
Divides every component by a number in place
vec4& opDivAssign(const vec4&in) /=
Divides by another vector component by component in place
bool opEquals(const vec4&in) const ==
Returns whether all components are exactly equal
vec4 opMul(float) const *
Multiplies every component by a number
vec4 opMul(const vec4&in) const *
Multiplies the vectors component by component
vec4& opMulAssign(float) *=
Multiplies every component by a number in place
vec4& opMulAssign(const vec4&in) *=
Multiplies by another vector component by component in place
vec4 opNeg() const -x
Returns the vector with all components negated
vec4 opSub(const vec4&in) const -
Subtracts two vectors
vec4& opSubAssign(const vec4&in) -=
Subtracts another vector in place

Properties

float length read-only
Length of the vector
float lengthSquared read-only
Squared length of the vector
float w
W component
float x
X component
float y
Y component
float z
Z component

Function documentation

void vec4::normalize()

Scales the vector in place to a length of 1

A zero-length vector becomes NaN in all components.

vec4 vec4::normalized() const

Returns a copy of the vector scaled to a length of 1

A zero-length vector gives NaN in all components.

Operator documentation

bool vec4::opEquals(const vec4&in) const ==

Returns whether all components are exactly equal

Use closeTo() on the components to allow for rounding errors.

Property documentation

float vec4::lengthSquared read-only

Squared length of the vector

Cheaper than the length, useful for comparing distances.