Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
vec4< T > Struct Template Reference

A four dimensional Cartesian-space vector template. More...

#include <geom.h>

Public Member Functions

 vec4 ()
 
 vec4 (const vec &p, T w=0)
 
 vec4 (const vec2 &p, T z=0, T w=0)
 
 vec4 (T x, T y=0, T z=0, T w=0)
 
 vec4 (bvec v, uchar c)
 
 vec4 (bvec v)
 
 vec4 (const T *v)
 
template<class U>
 vec4 (const vec4< U > &p)
 
template<class U>
 operator vec4< U > ()
 
T & operator[] (int i)
 Returns the i-th dimension of this vec4.
 
operator[] (int i) const
 Returns the i-th dimension of this vec4.
 
T & r ()
 References the x coordinate of this vec4.
 
T & g ()
 References the y coordinate of this vec4.
 
T & b ()
 References the z coordinate of this vec4.
 
T & a ()
 References the w coordinate of this vec4.
 
r () const
 Returns the x coordinate of this vec4.
 
g () const
 Returns the y coordinate of this vec4.
 
b () const
 Returns the z coordinate of this vec4.
 
a () const
 Returns the w coordinate of this vec4.
 
const T * data () const
 Returns a raw pointer to the data of this vec4.
 
uint * mask ()
 Returns a raw unsigned int pointer to the data in this vec4.
 
bool operator== (const vec4 &o) const
 Returns whether two vec objects exactly match.
 
bool operator!= (const vec4 &o) const
 Returns whether two vec objects do not match.
 
dot3 (const vec4 &o) const
 Returns the 3 dimensional dot product between two 4-vecs.
 
dot3 (const vec &o) const
 Returns the 3 dimensional dot product between this and a 3D vec.
 
dot (const vec4 &o) const
 Returns the scalar product with another vec4.
 
dot (const vec &o) const
 Returns the dot product of this and a vec3, assuming o.w = 1.
 
squaredlen () const
 Returns the square of the magnitude of the vector.
 
magnitude () const
 Returns the magnitude of the vector.
 
magnitude3 () const
 Returns the magnitude of the vector, ignoring the w dimension.
 
vec4normalize ()
 Scales the vector to have a magnitude of 1.
 
vec4safenormalize ()
 Scales the vector to have a magnitude of 1.
 
void lerp (const vec4< uchar > &a, const vec4< uchar > &b, float t)
 
void lerp (const vec4< uchar > &a, const vec4< uchar > &b, int ka, int kb, int d)
 
void lerp (const vec4< uchar > &a, const vec4< uchar > &b, const vec4< uchar > &c, float ta, float tb, float tc)
 
void flip ()
 Flips a vec4<uchar> by using the mask type pun.
 
vec4lerp (const vec4 &b, T t)
 
vec4lerp (const vec4 &a, const vec4 &b, T t)
 
vec4avg (const vec4 &b)
 Calculates the elementwise arithmetic mean.
 
template<class B>
vec4madd (const vec4 &a, const B &b)
 Sets this vec4 to the result of the multiply add of this with a,b
 
template<class B>
vec4msub (const vec4 &a, const B &b)
 Sets this vec4 to the result of the multiply subtract of this with a,b
 
vec4mul3 (T f)
 Calculates the elementwise product.
 
vec4mul (T f)
 Calculates the elementwise product.
 
vec4mul (const vec4 &o)
 Calculates the elementwise product.
 
vec4mul (const vec &o)
 Calculates the elementwise product.
 
vec4square ()
 Calculates the elementwise square.
 
vec4div3 (T f)
 Calculates the elementwise quotient.
 
vec4div (T f)
 Calculates the elementwise quotient.
 
vec4div (const vec4 &o)
 Calculates the elementwise quotient.
 
vec4div (const vec &o)
 Calculates the elementwise quotient.
 
vec4recip ()
 Calculates the elementwise reciprocal.
 
vec4add (const vec4 &o)
 Calculates the elementwise sum.
 
vec4add (const vec &o)
 Calculates the elementwise sum.
 
vec4add3 (T f)
 Calculates the elementwise sum.
 
vec4add (T f)
 Calculates the elementwise sum.
 
vec4addw (T f)
 Adds to the fourth value of the vector (w/a).
 
vec4sub (const vec4 &o)
 Subtracts from this the vec4 passed.
 
vec4sub (const vec &o)
 Subtracts from this the vec passed.
 
vec4sub3 (T f)
 Subtracts from the first three entries this the value passed.
 
vec4sub (T f)
 Subtracts from the entries this the value passed.
 
vec4subw (T f)
 Subtracts from the last element only.
 
vec4neg3 ()
 Negates the first three elements.
 
vec4neg ()
 Negates all of the elements.
 
vec4clamp (T l, T h)
 Clamps the elements individualy to the specified bounds.
 
vec4 operator+ (const vec4 &v2) const
 Returns a new vec4 object equal to the sum of the passed object and this
 
vec4 operator- (const vec4 &v2) const
 Returns a new vec4 object equal to this minus the passed object.
 
vec4 operator- () const
 Returns a new vec4 object equal to the arithmetic inverse of this
 
template<typename U>
vec4 operator* (const U &n) const
 Returns a new vec4 object equal to the scalar multiplication by a value.
 
vec4 operator* (const vec4 &v2) const
 Returns a new vec4 equal to the elementwise product of this and the passed vec4.
 
template<typename U>
vec4 operator/ (const U &n) const
 Returns a new vec4 object equal to the scalar division by a value.
 
vec4 operator/ (const vec4 &v2) const
 Returns a new vec4 equal to the elementwise division of this and the passed vec4.
 
template<class A, class B>
vec4cross (const A &a, const B &b)
 Sets this vec to the cross product of two passed objects.
 
vec4cross (const vec &o, const vec &a, const vec &b)
 Sets this vec4 to the cross product of a,b relative to an offset c.
 
void setxyz (const vec &v)
 Replaces the first three values of this with the passed vec.
 
vec4rotate_around_z (T c, T s)
 Rotates the given 3-vector around the z-axis.
 
vec4rotate_around_x (T c, T s)
 Rotates the given 3-vector around the x-axis.
 
vec4rotate_around_y (T c, T s)
 Rotates the given 3-vector around the y-axis.
 
vec4rotate_around_z (T angle)
 Conducts a rotation around the z-axis.
 
vec4rotate_around_x (T angle)
 Conducts a rotation around the x-axis.
 
vec4rotate_around_y (T angle)
 Conducts a rotation around the y-axis.
 
vec4rotate_around_z (const vec2 &sc)
 Conducts a rotation around the z-axis.
 
vec4rotate_around_x (const vec2 &sc)
 Conducts a rotation around the x-axis.
 
vec4rotate_around_y (const vec2 &sc)
 Conducts a rotation around the y-axis.
 
vec tonormal () const
 Returns a new vec containing values normalized to 0...255 (e.g. colors).
 

Public Attributes

x
 
y
 
z
 
w
 

Detailed Description

template<typename T>
struct vec4< T >

A four dimensional Cartesian-space vector template.

This object defines a location in four dimensional Cartesian space, in whatever arithmetic type it is specialized to be. All four values are of the type T specialized, and all operators (unless explicitly specified, require types trivially convertable to T (or preferably of type T).

Constructor & Destructor Documentation

◆ vec4()

template<typename T>
vec4< T >::vec4 ( )
inline

geometric space representation

Member Function Documentation

◆ a() [1/2]

template<typename T>
T & vec4< T >::a ( )
inline

References the w coordinate of this vec4.

Returns
a reference to w

◆ a() [2/2]

template<typename T>
T vec4< T >::a ( ) const
inline

Returns the w coordinate of this vec4.

Returns
the value of w

◆ add() [1/3]

template<typename T>
vec4 & vec4< T >::add ( const vec & o)
inline

Calculates the elementwise sum.

Calculates the sum of the first three elements in this with the first three values in o, element-by-element. This means that the original vector is not preserved.

Parameters
othe vector to add with
Returns
a reference to this object following the operation

◆ add() [2/3]

template<typename T>
vec4 & vec4< T >::add ( const vec4< T > & o)
inline

Calculates the elementwise sum.

Calculates the sum of the four elements in this with the four values in o, element-by-element. This means that the original vector is not preserved.

Parameters
othe vector to add with
Returns
a reference to this object following the operation

◆ add() [3/3]

template<typename T>
vec4 & vec4< T >::add ( T f)
inline

Calculates the elementwise sum.

Calculates the sum of the four elements in this with the four elements comprising f. This means that the original vector is not preserved.

Parameters
fthe value to add with
Returns
a reference to this object following the operation

◆ add3()

template<typename T>
vec4 & vec4< T >::add3 ( T f)
inline

Calculates the elementwise sum.

Calculates the sum of the first three elements in this with the value passed to f. This means that the original vector is not preserved.

Parameters
fthe value to add with
Returns
a reference to this object following the operation

◆ addw()

template<typename T>
vec4 & vec4< T >::addw ( T f)
inline

Adds to the fourth value of the vector (w/a).

Calculates the sum of the passed value and the fourth element of the vec4, modifying the original vector to equal this sum.

Parameters
fthe value to add with
Returns
a reference to this object following the operation

◆ avg()

template<typename T>
vec4 & vec4< T >::avg ( const vec4< T > & b)
inline

Calculates the elementwise arithmetic mean.

Sets this to the elementwise arithmetic mean of this object and the passed object. The original vector is not preserved, but the passed one is.

Parameters
bthe vec4 to average with
Returns
a reference to this object following the operation

◆ b() [1/2]

template<typename T>
T & vec4< T >::b ( )
inline

References the z coordinate of this vec4.

Returns
a reference to z

◆ b() [2/2]

template<typename T>
T vec4< T >::b ( ) const
inline

Returns the z coordinate of this vec4.

Returns
the value of z

◆ clamp()

template<typename T>
vec4 & vec4< T >::clamp ( T l,
T h )
inline

Clamps the elements individualy to the specified bounds.

Clamps each element such that none of them exceeds the bounds specified.

Parameters
lthe low value to clamp to
hthe high value to clamp to

◆ cross() [1/2]

template<typename T>
template<class A, class B>
vec4 & vec4< T >::cross ( const A & a,
const B & b )
inline

Sets this vec to the cross product of two passed objects.

The w field is unmodified. Only valid for vec-type objects with x,y,z scalar members.

Template Parameters
Athe type of the first cross product operand
Bthe type of the second cross product operand
Parameters
athe first cross product operand
bthe second cross product operand

◆ cross() [2/2]

template<typename T>
vec4 & vec4< T >::cross ( const vec & o,
const vec & a,
const vec & b )
inline

Sets this vec4 to the cross product of a,b relative to an offset c.

The w field is unmodified.

Parameters
othe origin to calculate offsets from
athe first vec to use
bthe second vec to use

◆ data()

template<typename T>
const T * vec4< T >::data ( ) const
inline

Returns a raw pointer to the data of this vec4.

Returns
a pointer to the lowest dimension (x) of this object

◆ div() [1/3]

template<typename T>
vec4 & vec4< T >::div ( const vec & o)
inline

Calculates the elementwise quotient.

Calculates the quotient of the three values in this with the four values in o, element-by-element. This means that the original vector is not preserved.

Parameters
othe vector to divide by
Returns
a reference to this object following the operation

◆ div() [2/3]

template<typename T>
vec4 & vec4< T >::div ( const vec4< T > & o)
inline

Calculates the elementwise quotient.

Calculates the quotient of the four values in this with the four values in o, element-by-element. This means that the original vector is not preserved.

Parameters
othe vector to divide by
Returns
a reference to this object following the operation

◆ div() [3/3]

template<typename T>
vec4 & vec4< T >::div ( T f)
inline

Calculates the elementwise quotient.

Calculates the quotient of the four values in this with the value passed to f. This means that the original vector is not preserved.

Parameters
fthe value to divide by
Returns
a reference to this object following the operation

◆ div3()

template<typename T>
vec4 & vec4< T >::div3 ( T f)
inline

Calculates the elementwise quotient.

Calculates the quotient of the first three values in this with the value passed to f. This means that the original vector is not preserved.

Parameters
fthe value to divide by
Returns
a reference to this object following the operation

◆ dot() [1/2]

template<typename T>
T vec4< T >::dot ( const vec & o) const
inline

Returns the dot product of this and a vec3, assuming o.w = 1.

Calculates the dot product with a vec3, with o.w implied to equal 1.

Parameters
othe vec3 to multiply by
Returns
the dot product of the two vectors

◆ dot() [2/2]

template<typename T>
T vec4< T >::dot ( const vec4< T > & o) const
inline

Returns the scalar product with another vec4.

Returns the scalar (dot) product of two 4D vecs, this and the passed vec4 o.

Parameters
othe vector to multiply with
Returns
the dot product of the two vectors

◆ dot3() [1/2]

template<typename T>
T vec4< T >::dot3 ( const vec & o) const
inline

Returns the 3 dimensional dot product between this and a 3D vec.

Returns the scalar (dot) product of a 3D and 4D vec, this and the passed 3D vec, by ignoring the fourth term in the 4D vec.

Parameters
othe vec3 to multiply by
Returns
the dot product of the first three elements of each vector

◆ dot3() [2/2]

template<typename T>
T vec4< T >::dot3 ( const vec4< T > & o) const
inline

Returns the 3 dimensional dot product between two 4-vecs.

Returns the scalar (dot) product of two 4D vecs, this and the passed one, as if they are 3D vecs, by ignoring the fourth term in each vector.

Parameters
othe vec4 to multiply by
Returns
the dot product of the first three elements of each vector

◆ flip()

template<typename T>
void vec4< T >::flip ( )
inline

Flips a vec4<uchar> by using the mask type pun.

Not for use with non-char vec4<> objects.

◆ g() [1/2]

template<typename T>
T & vec4< T >::g ( )
inline

References the y coordinate of this vec4.

Returns
a reference to y

◆ g() [2/2]

template<typename T>
T vec4< T >::g ( ) const
inline

Returns the y coordinate of this vec4.

Returns
the value of y

◆ madd()

template<typename T>
template<class B>
vec4 & vec4< T >::madd ( const vec4< T > & a,
const B & b )
inline

Sets this vec4 to the result of the multiply add of this with a,b

Returns a*b (elementwise multiplication) added with this (elementwise addition).

Parameters
avalue to multiply
bvalue to multiply
Returns
a reference to this following the operation

◆ magnitude()

template<typename T>
T vec4< T >::magnitude ( ) const
inline

Returns the magnitude of the vector.

Calculates the magnitude (length) of the vector, by taking the square root of the dot product of the vector with itself.

Returns
the maginitude of this

◆ magnitude3()

template<typename T>
T vec4< T >::magnitude3 ( ) const
inline

Returns the magnitude of the vector, ignoring the w dimension.

Calculates the D magnitude (length) of the vector, by taking the square root of the 3D dot product of the vector with itself.

Returns
the maginitude of this

◆ mask()

template<typename T>
uint * vec4< T >::mask ( )
inline

Returns a raw unsigned int pointer to the data in this vec4.

Returns
a unsigned int pointer to the lowest dimension (x) of this object

◆ msub()

template<typename T>
template<class B>
vec4 & vec4< T >::msub ( const vec4< T > & a,
const B & b )
inline

Sets this vec4 to the result of the multiply subtract of this with a,b

Returns a*b (elementwise multiplication) subtracted from this (elementwise subtraction).

Parameters
avalue to multiply
bvalue to multiply
Returns
a reference to this following the operation

◆ mul() [1/3]

template<typename T>
vec4 & vec4< T >::mul ( const vec & o)
inline

Calculates the elementwise product.

Calculates the elementwise product of the first three parameters in this with the three parameters in o. This means that the original vector is not preserved.

Parameters
othe vec3 to multiply by
Returns
a reference to this object following the operation

◆ mul() [2/3]

template<typename T>
vec4 & vec4< T >::mul ( const vec4< T > & o)
inline

Calculates the elementwise product.

Calculates the elementwise product of the four parameters in this with the four parameters in o. This measn that the original vector is not preserved.

Parameters
othe vec4 to multiply by
Returns
a reference to this object following the operation

◆ mul() [3/3]

template<typename T>
vec4 & vec4< T >::mul ( T f)
inline

Calculates the elementwise product.

Calculates the elementwise product of f with all four entries in this. This means that the original vector is not preserved.

Parameters
fthe value to multiply by
Returns
a reference to this object following the operation

◆ mul3()

template<typename T>
vec4 & vec4< T >::mul3 ( T f)
inline

Calculates the elementwise product.

Calculates the elementwise product of f with the first three entries in this. This means that the original vector is not preserved.

Parameters
fthe value to multiply by
Returns
a reference to this object following the operation

◆ neg()

template<typename T>
vec4 & vec4< T >::neg ( )
inline

Negates all of the elements.

Returns
a reference to this

◆ neg3()

template<typename T>
vec4 & vec4< T >::neg3 ( )
inline

Negates the first three elements.

w is left unchanged.

Returns
a reference to this

◆ normalize()

template<typename T>
vec4 & vec4< T >::normalize ( )
inline

Scales the vector to have a magnitude of 1.

Will cause a divide-by-zero if the vector is (0,0,0,0).

Returns
a reference to this vector

◆ operator!=()

template<typename T>
bool vec4< T >::operator!= ( const vec4< T > & o) const
inline

Returns whether two vec objects do not match.

If any value compares not equal (by floating point math rules), then the vec4s are considered not equal

Parameters
othe value to compare
Returns
true if any value does not match
false if all values in the vec4s exactly match

◆ operator*() [1/2]

template<typename T>
template<typename U>
vec4 vec4< T >::operator* ( const U & n) const
inline

Returns a new vec4 object equal to the scalar multiplication by a value.

Template Parameters
uscalar type to multiply with
Parameters
nscalar value to multiply with
Returns
a new vec4 equal to this * n

◆ operator*() [2/2]

template<typename T>
vec4 vec4< T >::operator* ( const vec4< T > & v2) const
inline

Returns a new vec4 equal to the elementwise product of this and the passed vec4.

Parameters
v2the vec4 to multiply with
Returns
a new vec4 equal to this * v2

◆ operator+()

template<typename T>
vec4 vec4< T >::operator+ ( const vec4< T > & v2) const
inline

Returns a new vec4 object equal to the sum of the passed object and this

Parameters
v2the other vec to add
Returns
a new vec4 containing their sum

◆ operator-() [1/2]

template<typename T>
vec4 vec4< T >::operator- ( ) const
inline

Returns a new vec4 object equal to the arithmetic inverse of this

Returns
a new vec4 equal to the arithmetic inverse

◆ operator-() [2/2]

template<typename T>
vec4 vec4< T >::operator- ( const vec4< T > & v2) const
inline

Returns a new vec4 object equal to this minus the passed object.

Parameters
v2the other vec to subtract with
Returns
a new vec4 containing their difference

◆ operator/() [1/2]

template<typename T>
template<typename U>
vec4 vec4< T >::operator/ ( const U & n) const
inline

Returns a new vec4 object equal to the scalar division by a value.

Template Parameters
uscalar type to divide with
Parameters
nscalar value to divide with
Returns
a new vec4 equal to this / n

◆ operator/() [2/2]

template<typename T>
vec4 vec4< T >::operator/ ( const vec4< T > & v2) const
inline

Returns a new vec4 equal to the elementwise division of this and the passed vec4.

Parameters
v2the vec4 to divide with
Returns
a new vec4 equal to this / v2

◆ operator==()

template<typename T>
bool vec4< T >::operator== ( const vec4< T > & o) const
inline

Returns whether two vec objects exactly match.

The two values must be exactly equal (by floating point math rules), and no tolerance is provided.

Parameters
othe value to compare
Returns
true if all values in the vec4s exactly match
false if any value does not match

◆ operator[]() [1/2]

template<typename T>
T & vec4< T >::operator[] ( int i)
inline

Returns the i-th dimension of this vec4.

0 = x 1 = y 2 = z 3 = w

All values other than these will return a reference to x.

Parameters
ithe index to access
Returns
reference to the value along the specified dimension

◆ operator[]() [2/2]

template<typename T>
T vec4< T >::operator[] ( int i) const
inline

Returns the i-th dimension of this vec4.

0 = x 1 = y 2 = z 3 = w

All values other than these will return the value of x.

Parameters
ithe index to access
Returns
the value along the specified dimension

◆ r() [1/2]

template<typename T>
T & vec4< T >::r ( )
inline

References the x coordinate of this vec4.

Returns
a reference to x

◆ r() [2/2]

template<typename T>
T vec4< T >::r ( ) const
inline

Returns the x coordinate of this vec4.

Returns
the value of x

◆ recip()

template<typename T>
vec4 & vec4< T >::recip ( )
inline

Calculates the elementwise reciprocal.

Calculates the value 1/x for each of the four values in the vector, and assigns them to this. This means that the original vector is not preserved

Returns
a reference to this object following the operation

◆ rotate_around_x() [1/3]

template<typename T>
vec4 & vec4< T >::rotate_around_x ( const vec2 & sc)
inline

Conducts a rotation around the x-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
sca vec2 containing the {cosine, sine} values to rotate with
Returns
a reference to this following the operation

◆ rotate_around_x() [2/3]

template<typename T>
vec4 & vec4< T >::rotate_around_x ( T angle)
inline

Conducts a rotation around the x-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
anglethe angle (in radians) to rotate by
Returns
a reference to this following the operation

◆ rotate_around_x() [3/3]

template<typename T>
vec4 & vec4< T >::rotate_around_x ( T c,
T s )
inline

Rotates the given 3-vector around the x-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
cthe raw cosine value to rotate by
sthe raw sine value to rotate by

◆ rotate_around_y() [1/3]

template<typename T>
vec4 & vec4< T >::rotate_around_y ( const vec2 & sc)
inline

Conducts a rotation around the y-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
sca vec2 containing the {cosine, sine} values to rotate with
Returns
a reference to this following the operation

◆ rotate_around_y() [2/3]

template<typename T>
vec4 & vec4< T >::rotate_around_y ( T angle)
inline

Conducts a rotation around the y-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
anglethe angle (in radians) to rotate by
Returns
a reference to this following the operation

◆ rotate_around_y() [3/3]

template<typename T>
vec4 & vec4< T >::rotate_around_y ( T c,
T s )
inline

Rotates the given 3-vector around the y-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
cthe raw cosine value to rotate by
sthe raw sine value to rotate by

◆ rotate_around_z() [1/3]

template<typename T>
vec4 & vec4< T >::rotate_around_z ( const vec2 & sc)
inline

Conducts a rotation around the z-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
sca vec2 containing the {cosine, sine} values to rotate with
Returns
a reference to this following the operation

◆ rotate_around_z() [2/3]

template<typename T>
vec4 & vec4< T >::rotate_around_z ( T angle)
inline

Conducts a rotation around the z-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
anglethe angle (in radians) to rotate by
Returns
a reference to this following the operation

◆ rotate_around_z() [3/3]

template<typename T>
vec4 & vec4< T >::rotate_around_z ( T c,
T s )
inline

Rotates the given 3-vector around the z-axis.

The w parameter is ignored. The positive direction of rotation is counterclockwise.

Parameters
cthe raw cosine value to rotate by
sthe raw sine value to rotate by

◆ safenormalize()

template<typename T>
vec4 & vec4< T >::safenormalize ( )
inline

Scales the vector to have a magnitude of 1.

Will return (0,0,0,0) if the vector passed (0,0,0,0).

Returns
a reference to this vector

◆ setxyz()

template<typename T>
void vec4< T >::setxyz ( const vec & v)
inline

Replaces the first three values of this with the passed vec.

Parameters
vthe vec to replace x,y,z of thiswith

◆ square()

template<typename T>
vec4 & vec4< T >::square ( )
inline

Calculates the elementwise square.

Calculates the elementwise product of this with itself. This means that the original vector is not preserved.

Returns
a reference to this object following the operation

◆ squaredlen()

template<typename T>
T vec4< T >::squaredlen ( ) const
inline

Returns the square of the magnitude of the vector.

Calculates the dot product of the vector with itself, yielding the square of the magnitude of the vec4.

Returns
the magnitude of this squared

◆ sub() [1/3]

template<typename T>
vec4 & vec4< T >::sub ( const vec & o)
inline

Subtracts from this the vec passed.

Calculates the difference between the four elements in this and the three elements of o, modifying the original vector to equal this difference.

Parameters
othe vec to subtract
Returns
a reference to this object following the operation

◆ sub() [2/3]

template<typename T>
vec4 & vec4< T >::sub ( const vec4< T > & o)
inline

Subtracts from this the vec4 passed.

Calculates the difference between the four elements in this and the four elements of o, modifying the original vector to equal this difference.

Parameters
othe vec4 to subtract
Returns
a reference to this object following the operation

◆ sub() [3/3]

template<typename T>
vec4 & vec4< T >::sub ( T f)
inline

Subtracts from the entries this the value passed.

Calculates the difference between the elements in this and the value passed, modifying the original vector to equal this difference.

Parameters
fthe value to subtract
Returns
a reference to this object following the operation

◆ sub3()

template<typename T>
vec4 & vec4< T >::sub3 ( T f)
inline

Subtracts from the first three entries this the value passed.

Calculates the difference between the first three elements in this and the value passed, modifying the original vector to equal this difference.

Parameters
fthe value to subtract
Returns
a reference to this object following the operation

◆ subw()

template<typename T>
vec4 & vec4< T >::subw ( T f)
inline

Subtracts from the last element only.

Calculates the difference between the last 'w' element in this and the value passed, modifying the original vector to equal this difference.

Parameters
fthe value to subtract
Returns
a reference to this object following the operation

◆ tonormal()

template<typename T>
vec vec4< T >::tonormal ( ) const
inline

Returns a new vec containing values normalized to 0...255 (e.g. colors).

w is not used in this calculation.

Returns
a vec containing the normalized values of x,y,z

The documentation for this struct was generated from the following file: