reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofVec4f Class Reference

#include <ofVec4f.h>

Public Member Functions

Construct a 4D vector
 ofVec4f ()
 
 ofVec4f (float _scalar)
 
 ofVec4f (float _x, float _y, float _z, float _w)
 
 ofVec4f (const ofVec2f &vec)
 
 ofVec4f (const ofVec3f &vec)
 
 ofVec4f (const glm::vec2 &vec)
 
 ofVec4f (const glm::vec3 &vec)
 
 ofVec4f (const glm::vec4 &vec)
 
 operator glm::vec4 () const
 
Access components
float * getPtr ()
 
const float * getPtr () const
 
float & operator[] (int n)
 
float operator[] (int n) const
 
void set (float _scalar)
 
void set (float _x, float _y, float _z, float _w)
 
void set (const ofVec4f &vec)
 
Comparison
bool operator== (const ofVec4f &vec) const
 
bool operator!= (const ofVec4f &vec) const
 
bool match (const ofVec4f &vec, float tolerance=0.0001f) const
 
Operators
ofVec4f operator+ (const ofVec4f &vec) const
 
ofVec4f operator+ (const float f) const
 
ofVec4foperator+= (const ofVec4f &vec)
 
ofVec4foperator+= (const float f)
 
ofVec4f operator- (const float f) const
 
ofVec4f operator- (const ofVec4f &vec) const
 
ofVec4f operator- () const
 
ofVec4foperator-= (const float f)
 
ofVec4foperator-= (const ofVec4f &vec)
 
ofVec4f operator* (const ofVec4f &vec) const
 
ofVec4f operator* (const float f) const
 
ofVec4foperator*= (const ofVec4f &vec)
 
ofVec4foperator*= (const float f)
 
ofVec4f operator/ (const ofVec4f &vec) const
 
ofVec4f operator/ (const float f) const
 
ofVec4foperator/= (const ofVec4f &vec)
 
ofVec4foperator/= (const float f)
 
Simple manipulations
ofVec4f getScaled (const float length) const
 Returns a new ofVec4f that is the result of scaling this vector up or down so that it has the requested length.
 
ofVec4fscale (const float length)
 Scales this vector up or down so that it has the requested length.
 
Distance
float distance (const ofVec4f &pnt) const
 Treats this vector and 'pnt' as points in 4D space and calculates the distance between them.
 
float squareDistance (const ofVec4f &pnt) const
 
Interpolation
ofVec4f getInterpolated (const ofVec4f &pnt, float p) const
 Performs a linear interpolation of this vector towards 'pnt'.
 
ofVec4finterpolate (const ofVec4f &pnt, float p)
 Performs a linear interpolation of this vector towards 'pnt'. This modifies the current vector to the interpolated value.
 
ofVec4f getMiddle (const ofVec4f &pnt) const
 Calculates and returns the midpoint (as a vector) between this vector and 'pnt'.
 
ofVec4fmiddle (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.
 
ofVec4faverage (const ofVec4f *points, int num)
 Sets this vector to be the average (center of gravity or centroid) of a given array of 'ofVec4f's.
 
Limit
ofVec4f getNormalized () const
 Returns a normalized copy of this vector.
 
ofVec4fnormalize ()
 Normalizes the vector. This changes the current vector to its normalized value.
 
ofVec4f getLimited (float max) const
 Returns a copy of this vector with its length (magnitude) restricted to a maximum of 'max' units by scaling down if necessary.
 
ofVec4flimit (float max)
 Restrict the length (magnitude) of this vector to a maximum of 'max' units by scaling down if necessary.
 
Measurement
float length () const
 Returns the length (magnitude) of this vector.
 
float lengthSquared () const
 
Calculations
float dot (const ofVec4f &vec) const
 Calculates and returns the dot product of this vector with 'vec'.
 

Public Attributes

float x
 
float y
 
float z
 
float w
 

Constructor & Destructor Documentation

◆ ofVec4f() [1/8]

ofVec4f::ofVec4f ( )

◆ ofVec4f() [2/8]

ofVec4f::ofVec4f ( float  _scalar)
explicit

◆ ofVec4f() [3/8]

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

◆ ofVec4f() [4/8]

ofVec4f::ofVec4f ( const ofVec2f vec)

◆ ofVec4f() [5/8]

ofVec4f::ofVec4f ( const ofVec3f vec)

◆ ofVec4f() [6/8]

ofVec4f::ofVec4f ( const glm::vec2 &  vec)

◆ ofVec4f() [7/8]

ofVec4f::ofVec4f ( const glm::vec3 &  vec)

◆ ofVec4f() [8/8]

ofVec4f::ofVec4f ( const glm::vec4 &  vec)

Member Function Documentation

◆ average()

ofVec4f & 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
pointsThe array of 'ofVec4f's used in the average calculation.
numThe number of ofVec4f objects in the array.

◆ distance()

float ofVec4f::distance ( const ofVec4f pnt) const

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

Parameters
pntThe vector used in the distance calculation with the current vector.
Returns
The distance between the two vectors in 4D space.

◆ dot()

float ofVec4f::dot ( const ofVec4f vec) const

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
vecThe vector used in the dot product calculation with this vector.
Returns
The dot product of this vector with 'vec'.

◆ getInterpolated()

ofVec4f ofVec4f::getInterpolated ( const ofVec4f pnt,
float  p 
) const

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

Parameters
pntThe vector the interpolation will be performed on.
pThe 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 ofVec4f::getLimited ( float  max) const

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

Parameters
maxThe maximum length of the new vector.
Returns
A copy of the current vector that is at most 'max' units long.

◆ getMiddle()

ofVec4f ofVec4f::getMiddle ( const ofVec4f pnt) const

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

Parameters
pntThe vector used in the midpoint calculation with this vector.
Returns
The midpoint between this vector and 'pnt' as an ofVec4f.

◆ getNormalized()

ofVec4f ofVec4f::getNormalized ( ) const

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() [1/2]

float * ofVec4f::getPtr ( )
inline

◆ getPtr() [2/2]

const float * ofVec4f::getPtr ( ) const
inline

◆ getScaled()

ofVec4f ofVec4f::getScaled ( const float  length) const

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

Parameters
lengthThe desired length of the new ofVec4f object.
Returns
The result of scaling the this vector up or down.

◆ interpolate()

ofVec4f & 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
pntThe vector the interpolation will be performed on.
pThe 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 ofVec4f::length ( ) const

Returns the length (magnitude) of this vector.

Returns
The magnitude of the current vector.

◆ lengthSquared()

float ofVec4f::lengthSquared ( ) const

◆ limit()

ofVec4f & ofVec4f::limit ( float  max)

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

Parameters
maxThe maximum length of the current vector.

◆ match()

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

◆ middle()

ofVec4f & 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
pntThe vector used in the midpoint calculation with this vector.
Returns
The midpoint between this vector and 'pnt' as an ofVec4f.

◆ normalize()

ofVec4f & 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).

◆ operator glm::vec4()

ofVec4f::operator glm::vec4 ( ) const

◆ operator!=()

bool ofVec4f::operator!= ( const ofVec4f vec) const

◆ operator*() [1/2]

ofVec4f ofVec4f::operator* ( const float  f) const

◆ operator*() [2/2]

ofVec4f ofVec4f::operator* ( const ofVec4f vec) const

◆ operator*=() [1/2]

ofVec4f & ofVec4f::operator*= ( const float  f)

◆ operator*=() [2/2]

ofVec4f & ofVec4f::operator*= ( const ofVec4f vec)

◆ operator+() [1/2]

ofVec4f ofVec4f::operator+ ( const float  f) const

◆ operator+() [2/2]

ofVec4f ofVec4f::operator+ ( const ofVec4f vec) const

◆ operator+=() [1/2]

ofVec4f & ofVec4f::operator+= ( const float  f)

◆ operator+=() [2/2]

ofVec4f & ofVec4f::operator+= ( const ofVec4f vec)

◆ operator-() [1/3]

ofVec4f ofVec4f::operator- ( ) const

◆ operator-() [2/3]

ofVec4f ofVec4f::operator- ( const float  f) const

◆ operator-() [3/3]

ofVec4f ofVec4f::operator- ( const ofVec4f vec) const

◆ operator-=() [1/2]

ofVec4f & ofVec4f::operator-= ( const float  f)

◆ operator-=() [2/2]

ofVec4f & ofVec4f::operator-= ( const ofVec4f vec)

◆ operator/() [1/2]

ofVec4f ofVec4f::operator/ ( const float  f) const

◆ operator/() [2/2]

ofVec4f ofVec4f::operator/ ( const ofVec4f vec) const

◆ operator/=() [1/2]

ofVec4f & ofVec4f::operator/= ( const float  f)

◆ operator/=() [2/2]

ofVec4f & ofVec4f::operator/= ( const ofVec4f vec)

◆ operator==()

bool ofVec4f::operator== ( const ofVec4f vec) const

◆ operator[]() [1/2]

float & ofVec4f::operator[] ( int  n)
inline

◆ operator[]() [2/2]

float ofVec4f::operator[] ( int  n) const
inline

◆ scale()

ofVec4f & ofVec4f::scale ( const float  length)

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

Parameters
lengthThe desired length of the vector.

◆ set() [1/3]

void ofVec4f::set ( const ofVec4f vec)

◆ set() [2/3]

void ofVec4f::set ( float  _scalar)

◆ set() [3/3]

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

◆ squareDistance()

float ofVec4f::squareDistance ( const ofVec4f pnt) const

Member Data Documentation

◆ w

float ofVec4f::w

◆ x

float ofVec4f::x

◆ y

float ofVec4f::y

◆ z

float ofVec4f::z

The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/math/ofVec4f.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/math/ofVec4f.cpp