pfVec4(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfVec4(3pf)NAMEpfVec4 - Set and operate on 4-component vectors
FUNCTION SPECIFICATION
#include <Performer/pr/pfVec4.h>
void* pfVec4::operator new(size_t);
void* pfVec4::operator new(size_t, void *arena);
pfVec4::pfVec4();
pfVec4::pfVec4(float x, float y, float z, float w);
void pfVec4::addScaled(pfVec3& dst, const pfVec3& v1, float s,
const pfVec3& v2);
void pfVec4::add(const pfVec4& v1, const pfVec4& v2);
int pfVec4::almostEqual(const pfVec4& v2, float tol);
void pfVec4::combine(float s1, const pfVec4& v1, float s2,
const pfVec4& v2);
void pfVec4::copy(const pfVec4& v);
float pfVec4::distance(const pfVec4& pt2);
float pfVec4::dot(const pfVec4& v2);
int pfVec4::equal(const pfVec4& v2);
float pfVec4::length(void);
void pfVec4::negate(const pfVec4& v);
float pfVec4::normalize(void);
void pfVec4::scale(float s, const pfVec4& v);
void pfVec4::set(float x, float y, float z, float w);
float pfVec4::sqrDistance(const pfVec4& pt2);
void pfVec4::sub(const pfVec4& v1, const pfVec4& v2);
void pfVec4::xform(const pfVec4& v, const pfMatrix& m);
float& pfVec4::operator [](int i);
Page 1
pfVec4(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfVec4(3pf)
const float& pfVec4::operator [](int i);
int pfVec4::operator ==(const pfVec4& v);
pfVec4 pfVec4::operator -() const;
pfVec4 pfVec4::operator +(const pfVec4& v);
pfVec4 pfVec4::operator -(const pfVec4& v);
pfVec4& pfVec4::operator =(const pfVec4& v);
pfVec4& pfVec4::operator *=(float d);
pfVec4& pfVec4::operator /=(float d);
pfVec4& pfVec4::operator +=(const pfVec4& v);
pfVec4& pfVec4::operator -=(const pfVec4& v);
pfVec4 pfVec4::operator *(const pfVec4& v, float d);
pfVec4 pfVec4::operator *(float d, const pfVec4& v);
pfVec4 pfVec4::operator /(const pfVec4& v, float d);
pfVec4 pfVec4::operator *(const pfVec4& v, const pfMatrix& m);
struct pfVec4 {
float vec[4];
};
DESCRIPTION
Math functions for 4-component vectors.
Most accesses to pfVec4 go through pfVec4::operator[], but pfVec4 is a
public struct whose data member vec is directly accessible, e.g. for
passing to a routine expecting a float* such as glColor4fv. The default
constructor pfVec4() is empty and does not initialize the values in the
vector. An initializing constructor pfVec4(float, float, float, float)
accepts the initial values for the vector. new(arena) allocates a pfVec4
from the specified memory arena, or from the heap if arena is NULL. new
allocates a pfVec4 from the default memory arena (pfGetSharedArena).
pfVec4s can also be created automatically on the stack or statically.
pfVec4s allocated with new should be deleted with pfDelete, not delete.
The name vec has been used below to indicate the pfVec4 on which the
member function is being invoked.
Page 2
pfVec4(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfVec4(3pf)
pfVec4::set: vec[0] = x, vec[1] = y, vec[2] = z, vec[3] = w . Macro
equivalent is PFSET_VEC4.
pfVec4::copy: vec = v. Macro equivalent is PFCOPY_VEC4.
pfVec4::negate: vec = -v. Macro equivalent is PFNEGATE_VEC4.
pfVec4::add: vec = v1 + v2. Sets vec to the sum of vectors v1 and v2.
Macro equivalent is PFADD_VEC4.
pfVec4::sub: vec = v1 - v2. Sets vec to the difference of v1 and v2.
Macro equivalent is PFSUB_VEC4.
pfVec4::scale: vec = s * v1. Sets vec to the vector v scaled by s.
Macro equivalent is PFSCALE_VEC4.
pfVec4::addScaled: vec = v1 + s * v2. Sets vec to the vector v1 plus the
vector v2 scaled by s. Macro equivalent is PFADD_SCALED_VEC4.
pfVec4::combine: vec = s1 * v1 + s2 * v2. Sets vec to be the linear
combination of v1 and v2 with scales s1 and s2, respectively. Macro
equivalent is PFCOMBINE_VEC4.
pfVec4::normalize: vec = vec / length(vec). Normalizes the vector vec to
have unit length and returns the original length of the vector.
pfVec4::xform: vec = v * m. Transforms v by the matrix m.
pfVec4::dot = vec dot v2 = vec[0] * v2[0] + vec[1] * v2[1] + vec[2] *
v2[2] + vec[3] * v2[3]. Returns dot product of the vectors v1 and v2.
Macro equivalent is PFDOT_VEC4.
pfVec4::length = |vec| = sqrt(vec dot vec). Returns length of the vector
vec. Macro equivalent is PFLENGTH_VEC4.
pfVec4::sqrDistance = (vec - v2) dot (vec - v2). Returns square of
distance between two points vec and v2. Macro equivalent is
PFSQR_DISTANCE_PT4.
pfVec4::distance = sqrt((vec - v2) dot (vec - v2)). Returns distance
between two points vec and v2. Macro equivalent is PFDISTANCE_PT4.
pfVec4::equal = (vec == v2). Tests for strict component-wise equality of
two vectors vec and v2 and returns FALSE or TRUE. Macro equivalent is
PFEQUAL_VEC4.
pfVec4::almostEqual. Tests for approximate component-wise equality of
two vectors vec and v2. It returns FALSE or TRUE depending on whether
the absolute value of the difference between each pair of components is
less than the tolerance tol. Macro equivalent is PFALMOST_EQUAL_VEC4.
float& operator [](int i) const float& operator [](int i) Accesses
indexed component of vector.
Page 3
pfVec4(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfVec4(3pf)
int operator ==(const pfVec4&) Equality comparison operator.
pfVec4 operator -() const Nondestructive unary negation - returns a new
vector.
pfVec4 operator +(const pfVec4&) pfVec4 operator -(const pfVec4&)
Component-wise binary vector addition and subtraction operators.
pfVec4& operator =(const pfVec4&) Vector assignment operator.
pfVec4& operator *=(float) pfVec4& operator /=(float) Component-wise
scalar multiplication and division operators.
pfVec4& operator +=(const pfVec4&) pfVec4& operator -=(const pfVec4&)
Component-wise vector addition and subtraction operators.
pfVec4 operator *(const pfVec4&, float) pfVec4 operator *(float d, const
pfVec4&) pfVec4 operator /(const pfVec4&, float) pfVec4 operator *(const
pfVec4&, const pfMatrix&) Component-wise binary scalar multiplication and
division operators.
Routines can accept the same vector as source, destination, or as a
repeated operand.
NOTES
When using overloaded operators in C++, assignment operators, e.g. "+=",
are somewhat more efficient than the corresponding binary operators, e.g.
"+", because the latter construct a temporary intermediate object. Use
assignment operators or macros for binary operations where optimal speed
is important.
C++ does not support array deletion (i.e. delete[]) for arrays of objects
allocated new operators that take additional arguments. Hence, the array
deletion operator delete[] should not be used on arrays of objects
created with new(arena) pfVec4[n].
SEE ALSO
pfMatrix, pfVec2, pfVec3
Page 4