pfVec3(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec3(3pf)NAME
pfAddScaledVec3, pfAddVec3, pfEqualVec3, pfAlmostEqualVec3,
pfCombineVec3, pfCopyVec3, pfCrossVec3, pfDistancePt3, pfDotVec3,
pfLengthVec3, pfNegateVec3, pfNormalizeVec3, pfScaleVec3, pfSetVec3,
pfSqrDistancePt3, pfSubVec3, pfXformVec3, pfXformPt3, pfFullXformPt3 -
Set and operate on 3-component vectors
FUNCTION SPECIFICATION
#include <Performer/pr.h>
#include <Performer/prmath.h>
void pfAddScaledVec3(pfVec3 dst, const pfVec3 v1, float s,
const pfVec3 v2);
void pfAddVec3(pfVec3 dst, const pfVec3 v1, const pfVec3 v2);
int pfEqualVec3(const pfVec3 v1, const pfVec3 v2);
int pfAlmostEqualVec3(const pfVec3 v1, const pfVec3 v2, float tol);
void pfCombineVec3(pfVec3 dst, float s1, const pfVec3 v1, float s2,
const pfVec3 v2);
void pfCopyVec3(pfVec3 dst, const pfVec3 v);
void pfCrossVec3(pfVec3 dst, const pfVec3 v1, const pfVec3 v2);
float pfDistancePt3(const pfVec3 pt1, const pfVec3 pt2);
float pfDotVec3(const pfVec3 v1, const pfVec3 v2);
float pfLengthVec3(const pfVec3 v);
void pfNegateVec3(pfVec3 dst, const pfVec3 v);
float pfNormalizeVec3(pfVec3 v);
void pfScaleVec3(pfVec3 dst, float s, const pfVec3 v);
void pfSetVec3(pfVec3 dst, float x, float y, float z);
float pfSqrDistancePt3(const pfVec3 pt1, const pfVec3 pt2);
void pfSubVec3(pfVec3 dst, const pfVec3 v1, const pfVec3 v2);
void pfXformVec3(pfVec3 dst, const pfVec3 v, const pfMatrix m);
void pfXformPt3(pfVec3 dst, const pfVec3 v, const pfMatrix m);
Page 1
pfVec3(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec3(3pf)
void pfFullXformPt3(pfVec3 dst, const pfVec3 v, const pfMatrix m);
typedef float pfVec3[3];
DESCRIPTION
Math functions for 3-component vectors. Most of these routines have
macro equivalents.
pfSetVec3(dst, x, y, z): dst[0] = x, dst[1] = y, dst[2] = z. Macro
equivalent is PFSET_VEC3.
pfCopyVec3(dst, v): dst = v. Macro equivalent is PFCOPY_VEC3.
pfNegateVec3(dst, v): dst = -v. Macro equivalent is PFNEGATE_VEC3.
pfAddVec3(dst, v1, v2): dst = v1 + v2. Sets dst to the sum of vectors v1
and v2. Macro equivalent is PFADD_VEC3.
pfSubVec3(dst, v1, v2): dst = v1 - v2. Sets dst to the difference of v1
and v2. Macro equivalent is PFSUB_VEC3.
pfScaleVec3(dst, s, v): dst = s * v1. Sets dst to the vector v scaled by
s. Macro equivalent is PFSCALE_VEC3.
pfAddScaledVec3(dst, v1, s, v2): dst = v1 + s * v2. Sets dst to the
vector v1 plus the vector v2 scaled by s. Macro equivalent is
PFADD_SCALED_VEC3.
pfCombineVec3(dst, s1, v1, s2, v2): dst = s1 * v1 + s2 * v2. Sets dst to
be the linear combination of v1 and v2 with scales s1 and s2,
respectively. Macro equivalent: PFCOMBINE_VEC3.
pfNormalizeVec3(v): v = v / length(v). Normalizes the vector v to have
unit length and returns the original length of the vector.
pfCrossVec3(dst, v1, v2): dst = v1 X v2. Sets dst to the cross-product
of two vectors v1 and v2.
pfXformVec3(dst, v, m): dst = v4 * m (v4[i]=v[i] i=0, 1, 2; v4[3] = 0).
Transforms v as a vector by the matrix m.
pfXformPt3(dst, v, m): dst = v4 * m (v4[i]=v[i] i=0, 1, 2; v4[3] = 1).
Transforms v as a point by the matrix m using the 4X3 submatrix.
pfFullXformPt3(dst, v, m): dst = v4 * m (v4[i]=v[i] i=0, 1, 2; v4[3] =
1). Transforms v as a point by the matrix m using the full 4X4 matrix
and scaling dst by the resulting w coordinate.
Page 2
pfVec3(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec3(3pf)
pfDotVec3(v1, v2) = v1 dot v2 = v1[0] * v2[0] + v1[1] * v2[1] + v1[2] *
v2[2]. Returns dot product of the vectors v1 and v2. Macro equivalent
is PFDOT_VEC3.
pfLengthVec3(v) = |v| = sqrt(v dot v). Returns length of the vector v.
Macro equivalent is PFLENGTH_VEC3.
pfSqrDistancePt3(v1, v2) = (v1 - v2) dot (v1 - v2). Returns square of
distance between two points v1 and v2. Macro equivalent is
PFSQR_DISTANCE_PT3.
pfDistancePt3(v1, v2) = sqrt((v1 - v2) dot (v1 - v2)). Returns distance
between two points v1 and v2. Macro equivalent is PFDISTANCE_PT3.
pfEqualVec3(v1, v2) = (v1 == v2). Tests for strict component-wise
equality of two vectors v1 and v2 and returns FALSE or TRUE. Macro
equivalent is PFEQUAL_VEC3.
pfAlmostEqualVec3(v1, v2, tol). Tests for approximate component-wise
equality of two vectors v1 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_VEC3.
Routines can accept the same vector as source, destination, or as a
repeated operand.
SEE ALSO
pfMatrix, pfVec2, pfVec4
Page 3