ofDocsdocumentation math ofVec4f

ofVec4f


average( ... )

ofVec4f & average(const ofVec4f *points, int num)

Sets this vector to be the average (center of gravity or centroid) of a given array of 'ofVec4f's.

Parameters:

points The array of 'ofVec4f's used in the average calculation.

num The number of ofVec4f objects in the array.


distance( ... )

float distance(const ofVec4f &pnt)

Treats this vector and 'pnt' as points in 4D space and calculates the distance between them.

Parameters:

pnt The vector used in the distance calculation with the current vector.

Returns: The distance between the two vectors in 4D space.


dot( ... )

float dot(const ofVec4f &vec)

Calculates and returns the dot product of this vector with 'vec'.

Dot product (less commonly known as Euclidean inner product) expresses the angular relationship between two vectors. In other words it is a measure of how parallel two vectors are. If they are completely perpendicular the dot product is 0; if they are completely parallel their dot product is either 1 if they are pointing in the same direction, or -1 if they are pointing in opposite directions.

Parameters:

vec The vector used in the dot product calculation with this vector.

Returns: The dot product of this vector with 'vec'.


getInterpolated( ... )

ofVec4f getInterpolated(const ofVec4f &pnt, float p)

Performs a linear interpolation of this vector towards 'pnt'.

Parameters:

pnt The vector the interpolation will be performed on.

p The amount to move towards 'pnt'; 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'.

Returns: The interpolation as an ofVec4f.


getLimited( ... )

ofVec4f getLimited(float max)

Returns a copy of this vector with its length (magnitude) restricted to a maximum of 'max' units by scaling down if necessary.

Parameters:

max The maximum length of the new vector.

Returns: A copy of the current vector that is at most 'max' units long.


getMiddle( ... )

ofVec4f getMiddle(const ofVec4f &pnt)

Calculates and returns the midpoint (as a vector) between this vector and 'pnt'.

Parameters:

pnt The vector used in the midpoint calculation with this vector.

Returns: The midpoint between this vector and 'pnt' as an ofVec4f.


getNormalized( )

ofVec4f getNormalized()

Returns a normalized copy of this vector.

Normalization means to scale the vector so that its length (magnitude) is exactly 1, at which stage all that is left is the direction. A normalized vector is usually called a unit vector, and can be used to represent a pure direction (heading).

Returns: The normalized copy of the current vector.


getPtr( )

float * getPtr()

\name Access components {


getPtr( )

const float * getPtr()

getScaled( ... )

ofVec4f getScaled(const float length)

Returns a new ofVec4f that is the result of scaling this vector up or down so that it has the requested length.

Parameters:

length The desired length of the new ofVec4f object.

Returns: The result of scaling the this vector up or down.


interpolate( ... )

ofVec4f & interpolate(const ofVec4f &pnt, float p)

Performs a linear interpolation of this vector towards 'pnt'. This modifies the current vector to the interpolated value.

Parameters:

pnt The vector the interpolation will be performed on.

p The amount to move towards 'pnt'; 'p' is normally between 0 and 1 and where 0 means stay the original position and 1 means move all the way to 'pnt', but you can also have 'p' greater than 1 overshoot 'pnt', or less than 0 to move backwards away from 'pnt'.


length( )

float length()

Returns the length (magnitude) of this vector.

Returns: The magnitude of the current vector.


lengthSquared( )

float lengthSquared()

limit( ... )

ofVec4f & limit(float max)

Restrict the length (magnitude) of this vector to a maximum of 'max' units by scaling down if necessary.

Parameters:

max The maximum length of the current vector.


match( ... )

bool match(const ofVec4f &vec, float tolerance=0.0001f)

middle( ... )

ofVec4f & middle(const ofVec4f &pnt)

Calculates and returns the midpoint (as a vector) between this vector and 'pnt'. This modifies the current vector to the midpoint value.

Parameters:

pnt The vector used in the midpoint calculation with this vector.

Returns: The midpoint between this vector and 'pnt' as an ofVec4f.


normalize( )

ofVec4f & normalize()

Normalizes the vector. This changes the current vector to its normalized value.

Normalization means to scale the vector so that its length (magnitude) is exactly 1, at which stage all that is left is the direction. A normalized vector is usually called a unit vector, and can be used to represent a pure direction (heading).


ofVec4f( ... )

ofVec4f(const ofVec2f &vec)

ofVec4f( ... )

ofVec4f(const ofVec3f &vec)

ofVec4f( ... )

ofVec4f(const glm::vec2 &vec)

ofVec4f( ... )

ofVec4f(const glm::vec3 &vec)

ofVec4f( ... )

ofVec4f(const glm::vec4 &vec)

ofVec4f( )

ofVec4f()

\name Construct a 4D vector {


ofVec4f( ... )

ofVec4f(float _scalar)

ofVec4f( ... )

ofVec4f(float _x, float _y, float _z, float _w)

one( )

ofVec4f one()

operator!=( ... )

bool operator!=(const ofVec4f &vec)

operator*( ... )

ofVec4f operator*(const ofVec4f &vec)

operator*( ... )

ofVec4f operator*(const float f)

operator*=( ... )

ofVec4f & operator*=(const ofVec4f &vec)

operator*=( ... )

ofVec4f & operator*=(const float f)

operator+( ... )

ofVec4f operator+(const ofVec4f &vec)

\name Operators {


operator+( ... )

ofVec4f operator+(const float f)

operator+=( ... )

ofVec4f & operator+=(const ofVec4f &vec)

operator+=( ... )

ofVec4f & operator+=(const float f)

operator-( ... )

ofVec4f operator-(const ofVec4f &vec)

operator-( )

ofVec4f operator-()

operator-( ... )

ofVec4f operator-(const float f)

operator-=( ... )

ofVec4f & operator-=(const ofVec4f &vec)

operator-=( ... )

ofVec4f & operator-=(const float f)

operator/( ... )

ofVec4f operator/(const ofVec4f &vec)

operator/( ... )

ofVec4f operator/(const float f)

operator/=( ... )

ofVec4f & operator/=(const ofVec4f &vec)

operator/=( ... )

ofVec4f & operator/=(const float f)

operator==( ... )

bool operator==(const ofVec4f &vec)

\name Comparison {


operator[]( ... )

float & operator[](int n)

operator[]( ... )

float operator[](int n)

scale( ... )

ofVec4f & scale(const float length)

Scales this vector up or down so that it has the requested length.

Parameters:

length The desired length of the vector.


set( ... )

void set(const ofVec4f &vec)

set( ... )

void set(float _scalar)

set( ... )

void set(float _x, float _y, float _z, float _w)

squareDistance( ... )

float squareDistance(const ofVec4f &pnt)

zero( )

ofVec4f zero()