pfVec2(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec2(3pf)NAME
pfAddScaledVec2, pfAddVec2, pfAlmostEqualVec2, pfCombineVec2, pfCopyVec2,
pfDistancePt2, pfDotVec2, pfEqualVec2, pfLengthVec2, pfNegateVec2,
pfNormalizeVec2, pfScaleVec2, pfSetVec2, pfSqrDistancePt2, pfSubVec2 -
Set and operate on 2-component vectors
FUNCTION SPECIFICATION
#include <Performer/pr.h>
#include <Performer/prmath.h>
void pfAddScaledVec2(pfVec2 dst, const pfVec2 v1, float s,
const pfVec2 v2);
void pfAddVec2(pfVec2 dst, const pfVec2 v1, const pfVec2 v2);
int pfAlmostEqualVec2(const pfVec2 v1, const pfVec2 v2, float tol);
void pfCombineVec2(pfVec2 dst, float s1, const pfVec2 v1, float s2,
const pfVec2 v2);
void pfCopyVec2(pfVec2 dst, const pfVec2 v);
float pfDistancePt2(const pfVec2 pt1, const pfVec2 pt2);
float pfDotVec2(const pfVec2 v1, const pfVec2 v2);
int pfEqualVec2(const pfVec2 v1, const pfVec2 v2);
float pfLengthVec2(const pfVec2 v);
void pfNegateVec2(pfVec2 dst, const pfVec2 v);
float pfNormalizeVec2(pfVec2 v);
void pfScaleVec2(pfVec2 dst, float s, const pfVec2 v);
void pfSetVec2(pfVec2 dst, float x, float y);
float pfSqrDistancePt2(const pfVec2 pt1, const pfVec2 pt2);
void pfSubVec2(pfVec2 dst, const pfVec2 v1, const pfVec2 v2);
typedef float pfVec2[2];
DESCRIPTION
Math functions for 2-component vectors. Most of these routines have
macro equivalents.
Page 1
pfVec2(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec2(3pf)
pfSetVec2(dst, x, y): dst[0] = x, dst[1] = y. Macro equivalent is
PFSET_VEC2.
pfCopyVec2(dst, v): dst = v. Macro equivalent is PFCOPY_VEC2.
pfNegateVec2(dst, v): dst = -v. Macro equivalent is PFNEGATE_VEC2.
pfAddVec2(dst, v1, v2): dst = v1 + v2. Sets dst to the sum of vectors v1
and v2. Macro equivalent is PFADD_VEC2.
pfSubVec2(dst, v1, v2): dst = v1 - v2. Sets dst to the difference of v1
and v2. Macro equivalent is PFSUB_VEC2.
pfAddScaledVec2(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_VEC2.
pfScaleVec2(dst, s, v): dst = s * v1. Sets dst to the vector v scaled by
s. Macro equivalent is PFSCALE_VEC2.
pfCombineVec2(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_VEC2.
pfNormalizeVec2(v): v = v / length(v). Normalizes the vector v to have
unit length and returns the original length of the vector.
pfDotVec2(v1, v2) = v1 dot v2 = v1[0] * v2[0] + v1[1] * v2[1] . Returns
dot product of the vectors v1 and v2. Macro equivalent is PFDOT_VEC2.
pfLengthVec2(v) = |v| = sqrt(v dot v). Returns length of the vector v.
Macro equivalent is PFLENGTH_VEC2.
pfSqrDistancePt2(v1, v2) = (v1 - v2) dot (v1 - v2). Returns square of
distance between two points v1 and v2. Macro equivalent is
PFSQR_DISTANCE_PT2.
pfDistancePt2(v1, v2) = sqrt((v1 - v2) dot (v1 - v2)). Returns distance
between two points v1 and v2. Macro equivalent is PFDISTANCE_PT2.
pfEqualVec2(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_VEC2.
pfAlmostEqualVec2(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_VEC2.
Routines can accept the same vector as source, destination, or as a
repeated operand.
Page 2
pfVec2(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfVec2(3pf)SEE ALSO
pfMatrix, pfVec3, pfVec4
Page 3