|
| AffVector () |
|
| AffVector (const AffVector &v) |
|
| AffVector (const AffPoint &p) |
|
| AffVector (double Dx, double Dy, double Dz=0.0) |
|
| AffVector (const double xyz[]) |
|
| AffVector (const float xyz[]) |
|
virtual | ~AffVector () |
|
AffVector | operator= (const AffVector &rhs) |
|
AffVector | operator+= (const AffVector &rhs) |
|
AffVector | operator-= (const AffVector &rhs) |
|
AffVector | operator*= (double f) |
|
AffVector | operator/= (double f) |
|
double | operator[] (int index) const |
|
AffVector | operator+ (const AffVector &v2) const |
|
AffVector | operator- (const AffVector &v2) const |
|
AffVector | operator- () const |
|
AffVector | operator* (double f) const |
|
AffVector | operator/ (double f) const |
|
void | arbitraryNormal (AffVector &normal) const |
|
void | assign (double dxx, double dyy, double dzz) |
|
AffVector | cross (const AffVector &rhs) const |
|
void | decompose (const AffVector &arbitraryVector, AffVector ¶llel, AffVector &perpendicular) const |
|
double | dot (const AffVector &rhs) const |
|
double | length () const |
|
double | lengthSquared () const |
|
double | maxAbsComponent (int &componentIndex) const |
|
double | minAbsComponent (int &componentIndex) const |
|
double | normalize () |
|
double | normalizeToCopy (AffVector &normalizedCopy) const |
|
bool | parallelTo (const AffVector &v) const |
|
void | swizzle (char xyz[3]) |
|
double * | vComponents (double *components, int offset=0) const |
|
double * | vComponents (double components[][3], int offset=0) const |
|
float * | vComponents (float *components, int offset=0) const |
|
float * | vComponents (float components[][3], int offset=0) const |
|
cryph::AffVector::AffVector |
( |
| ) |
|
Default constructor creates a zero vector
cryph::AffVector::AffVector |
( |
const AffVector & |
v | ) |
|
The copy constructor
- Parameters
-
v | [INPUT ONLY] the vector whose components are used to initialize "this" vector |
cryph::AffVector::AffVector |
( |
const AffPoint & |
p | ) |
|
Construct a vector from a point (i.e., "this" vector = p - origin)
- Parameters
-
cryph::AffVector::AffVector |
( |
double |
Dx, |
|
|
double |
Dy, |
|
|
double |
Dz = 0.0 |
|
) |
| |
Creates a vector with the given components
- Parameters
-
Dx | [INPUT ONLY] the x component |
Dy | [INPUT ONLY] the y component |
Dz | [INPUT ONLY] the z component (defaults to 0.0) |
cryph::AffVector::AffVector |
( |
const double |
xyz[] | ) |
|
Construct from a double array
- Parameters
-
xyz | [INPUT ONLY] an array assumed to be length 3 holding (dx, dy, dz) |
cryph::AffVector::AffVector |
( |
const float |
xyz[] | ) |
|
Construct from a float array
- Parameters
-
xyz | [INPUT ONLY] an array assumed to be length 3 holding (dx, dy, dz) |
cryph::AffVector::~AffVector |
( |
| ) |
|
|
virtual |
void cryph::AffVector::arbitraryNormal |
( |
AffVector & |
normal | ) |
const |
Generate a vector normal to "this" vector and return in formal parameter
- Parameters
-
normal | [OUTPUT ONLY] the output normal vector computed |
void cryph::AffVector::assign |
( |
double |
dxx, |
|
|
double |
dyy, |
|
|
double |
dzz |
|
) |
| |
Reset the (dx, dy, dz) components of this vector
- Parameters
-
dxx | [INPUT ONLY] the new dx |
dyy | [INPUT ONLY] the new dy |
dzz | [INPUT ONLY] the new dz |
Create a right-handed orthonormal coordinate system from the given U and W vectors. If W is a zero vector, then U, V, and W will be set to (1,0,0), (0,1,0), and (0,0,1), respectively. Otherwise, W is normalized, and the component of U perpendicular to W is computed. If that is zero (including the case that U itself is (0,0,0)), then an arbitrary vector perpendicular to W is created, normalized, and assigned to U. Finally, V ← W x U.
- Parameters
-
U | [INPUT/OUTPUT] Used and modified as explained above. |
V | [OUTPUT ONLY] Computed as explained above. |
W | [INPUT/OUTPUT] Used and modified as explained above. |
- See also
- coordinateSystemFromVW
Create a right-handed orthonormal coordinate system from the given V and W vectors. If W is a zero vector, then U, V, and W will be set to (1,0,0), (0,1,0), and (0,0,1), respectively. Otherwise, W is normalized, and the component of V perpendicular to W is computed. If that is zero (including the case that V itself is (0,0,0)), then an arbitrary vector perpendicular to W is created, normalized, and assigned to V. Finally, U ← V x W.
- Parameters
-
U | [OUTPUT ONLY] Computed as explained above. |
V | [INPUT/OUTPUT] Used and modified as explained above. |
W | [INPUT/OUTPUT] Used and modified as explained above. |
- See also
- coordinateSystemFromUW
Compute and return the cross product: "this" x rhs
- Parameters
-
rhs | [INPUT ONLY] the second vector in the cross product |
- Returns
- the computed cross product
Compute and return the cross product of the two given vectors
- Parameters
-
v1 | [INPUT ONLY] The first vector of the cross product |
v2 | [INPUT ONLY] The second vector of the cross product |
- Returns
- the cross product: v1 x v2
Decompose an arbitrary vector into its components parallel to and perpendicular to "this" vector.
- Parameters
-
arbitraryVector | [INPUT ONLY] the vector to decompose |
parallel | [OUTPUT ONLY] the component of "arbitraryVector" parallel to "this" vector |
perpendicular | [OUTPUT ONLY] the component of "arbitraryVector" perpendicular to "this" vector |
double cryph::AffVector::dot |
( |
const AffVector & |
rhs | ) |
const |
|
inline |
Compute and return the dot product of "this" vector with "rhs"
- Parameters
-
rhs | [INPUT ONLY] the second vector in the dot product |
- Returns
- the dot product of "this" vector and "rhs" vector
Compute and return the dot product of the two given vectors
- Parameters
-
v1 | [INPUT ONLY] The first vector of the dot product |
v2 | [INPUT ONLY] The second vector of the dot product |
- Returns
- the dot product: v1 . v2
double cryph::AffVector::length |
( |
| ) |
const |
|
inline |
Compute and return the length of "this" vector
double cryph::AffVector::lengthSquared |
( |
| ) |
const |
|
inline |
Compute and return the length squared of "this" vector
double cryph::AffVector::maxAbsComponent |
( |
int & |
componentIndex | ) |
const |
Determine the component of this vector with the largest absolute value
- Parameters
-
componentIndex | [OUTPUT ONLY] the index (0, 1, or 2) of the component with the largest absolute value |
- Returns
- the value of the component with the largest absolute value
double cryph::AffVector::minAbsComponent |
( |
int & |
componentIndex | ) |
const |
Determine the component of this vector with the smallest absolute value
- Parameters
-
componentIndex | [OUTPUT ONLY] the index (0, 1, or 2) of the component with the smallest absolute value |
- Returns
- the value of the component with the smallest absolute value
double cryph::AffVector::normalize |
( |
| ) |
|
Normalize "this" vector
- Returns
- the length of the vector before it was normalized
double cryph::AffVector::normalizeToCopy |
( |
AffVector & |
normalizedCopy | ) |
const |
Compute a unit vector in the direction of "this" vector, placing it in "normalizedCopy". Leave "this" vector unchanged.
- Parameters
-
normalizedCopy | [OUTPUT ONLY] the vector to hold the computed unit vector |
- Returns
- the length of "this" vector"
AffVector cryph::AffVector::operator* |
( |
double |
f | ) |
const |
|
inline |
Scales "this" vector by f and returns the result as an AffVewctor
- Parameters
-
f | [INPUT ONLY] the scale factor |
- Returns
- the scaled AffVector
AffVector cryph::AffVector::operator*= |
( |
double |
f | ) |
|
Scales the components of "this" vector by f
- Parameters
-
f | [INPUT ONLY] the scale factor |
- Returns
- the value of the scaled AffVector
Adds "this" vector to v2 and returns the result as an AffVector
- Parameters
-
v2 | [INPUT ONLY] the vector to add |
- Returns
- the sum of "this" vector and v2
Adds the components of rhs to "this" vector
- Parameters
-
rhs | [INPUT ONLY] a const reference to an AffVector |
- Returns
- the result of incrementing AffVector
Subtracts v2 from "this" vector and returns the result as an AffVector
- Parameters
-
v2 | [INPUT ONLY] the vector to subtract |
- Returns
- the difference of the two vectors
AffVector cryph::AffVector::operator- |
( |
| ) |
const |
|
inline |
Unary negation operator.
- Returns
- the negated value of "this" vector
Subtracts the components of rhs from "this" vector
- Parameters
-
rhs | [INPUT ONLY] a const reference to an AffVector |
- Returns
- the result of decrementing the AffVector
AffVector cryph::AffVector::operator/ |
( |
double |
f | ) |
const |
|
inline |
Divide "this" vector by f (i.e., scale by 1/f)
- Parameters
-
f | [INPUT ONLY] the divisor |
- Returns
- the AffVector divided by f
AffVector cryph::AffVector::operator/= |
( |
double |
f | ) |
|
Divides the components of "this" vector by f (i.e., scales it by 1/f)
- Parameters
-
f | [INPUT ONLY] the divisor |
- Returns
- the value of the divided AffVector
Assigns the components of rhs to "this" vector
- Parameters
-
rhs | [INPUT ONLY] a const reference to an AffVector |
- Returns
- the value assigned
double cryph::AffVector::operator[] |
( |
int |
index | ) |
const |
Returns dx (if index = 0); dy If index = 1); dz (if index = 2) The returned value cannot be used as an kl-value.
- Returns
- the selected vector component
bool cryph::AffVector::parallelTo |
( |
const AffVector & |
v | ) |
const |
Determine whether "this" vector is parallel to "v".
- Parameters
-
v | [INPUT ONLY] the vector to be compared to "this" vector |
- Returns
- true if the vectors are parallel; false otherwise
void cryph::AffVector::swizzle |
( |
char |
xyz[3] | ) |
|
A method inspired by OpenGL's GLSL's swizzle operation. If the i-th character of xyz is 'X', then the x component of "this" vector is placed into the i-th component of "this" vector. If instead it is 'x', then negative of the x component of "this" vector is placed into the i-th component of "this" vector. Characters 'y', 'Y', 'z', 'Z' behave similarly. Any other character is simply ignored. Some examples:
cryph::AffVector av(1.0, 2.0, 3.0);
av.swizzle("Zxy"); // av is now (3.0, -1.0, -2.0)
av.swizzle("dzy"); // av is now (3.0, 2.0, 1.0)
av.swizzle("xxY"); // av is now (3.0, 3.0, 2.0)
- Parameters
-
xyz | [INPUT ONLY] an array of char of length 3 interpreted as explained and illustrated above |
double * cryph::AffVector::vComponents |
( |
double * |
components, |
|
|
int |
offset = 0 |
|
) |
| const |
Extract the components of "this" vector into an array of double, starting at the given offset. Among other things, this method is useful for interfacing with OpenGL, especially routines like glBufferData. For example, a caller can allocate an array of an appropriate size, then loop over an array of AffVector instances, invoking the vComponents method as follows:
double* buf = new double[3*NUM_VECTORS];
for (int i=0 ; i<NUM_VECTORS ; i++)
affVectorArray[i].vComponents(buf, 3*i);
glBufferData(GL_ARRAY_BUFFER, 3*NUM_VECTORS*sizeof(double), buf, GL_STATIC_DRAW);
delete [] buf;
- Parameters
-
components | [OUTPUT ONLY] the array into which the (dx, dy, dz) components of "this" vector are to be copied. Must be at least (offset+3) positions long. |
offset | [INPUT ONLY] the starting location in components where the components are to be placed (defaults to 0) |
- Returns
- the given components array pointer so that the method call can be used as a parameter to an OpenGL function expecting an array of double
double * cryph::AffVector::vComponents |
( |
double |
components[][3], |
|
|
int |
offset = 0 |
|
) |
| const |
Extract the components of "this" vector into an array of "dvec3" (a built-in GLSL data type essentially equivalent to "typedef double
dvec3[3];"), starting at the given offset. Among other things, this method is useful for interfacing with OpenGL, especially routines like glBufferData. For example, a caller can allocate an array of an appropriate size, then loop over an array of AffVector instances, invoking the vComponents method as follows:
dvec3* buf = new dvec3[3*NUM_VECTORS]; // assuming the "typedef" above
for (int i=0 ; i<NUM_VECTORS ; i++)
affVectorArray[i].vComponents(buf, i);
glBufferData(GL_ARRAY_BUFFER, NUM_VECTORS*sizeof(double), buf, GL_STATIC_DRAW);
delete [] buf;
- Parameters
-
components | [OUTPUT ONLY] the array into which the (dx, dy, dz) components of "this" vector are to be copied. Must be at least (offset+1) positions long. |
offset | [INPUT ONLY] the starting location in components where the components are to be placed (defaults to 0) |
- Returns
- the given components array pointer so that the method call can be used as a parameter to an OpenGL function expecting an array of double
float * cryph::AffVector::vComponents |
( |
float * |
components, |
|
|
int |
offset = 0 |
|
) |
| const |
Extract the components of "this" vector into an array of float, starting at the given offset. Among other things, this method is useful for interfacing with OpenGL, especially routines like glBufferData. For example, a caller can allocate an array of an appropriate size, then loop over an array of AffVector instances, invoking the vComponents method as follows:
float* buf = new float[3*NUM_VECTORS];
for (int i=0 ; i<NUM_VECTORS ; i++)
affVectorArray[i].vComponents(buf, 3*i);
glBufferData(GL_ARRAY_BUFFER, 3*NUM_VECTORS*sizeof(float), buf, GL_STATIC_DRAW);
delete [] buf;
- Parameters
-
components | [OUTPUT ONLY] the array into which the (dx, dy, dz) components of "this" vector are to be copied. Must be at least (offset+3) positions long. |
offset | [INPUT ONLY] the starting location in components where the components are to be placed (defaults to 0) |
- Returns
- the given components array pointer so that the method call can be used as a parameter to an OpenGL function expecting an array of float
float * cryph::AffVector::vComponents |
( |
float |
components[][3], |
|
|
int |
offset = 0 |
|
) |
| const |
Extract the components of "this" vector into an array of "vec3" (a built-in GLSL data type essentially equivalent to "typedef float
vec3[3];"), starting at the given offset. Among other things, this method is useful for interfacing with OpenGL, especially routines like glBufferData. For example, a caller can allocate an array of an appropriate size, then loop over an array of AffVector instances, invoking the vComponents method as follows:
vec3* buf = new vec3[3*NUM_VECTORS]; // assuming the "typedef" above
for (int i=0 ; i<NUM_VECTORS ; i++)
affVectorArray[i].vComponents(buf, i);
glBufferData(GL_ARRAY_BUFFER, NUM_VECTORS*sizeof(float), buf, GL_STATIC_DRAW);
delete [] buf;
- Parameters
-
components | [OUTPUT ONLY] the array into which the (dx, dy, dz) components of "this" vector are to be copied. Must be at least (offset+1) positions long. |
offset | [INPUT ONLY] the starting location in components where the components are to be placed (defaults to 0) |
- Returns
- the given components array pointer so that the method call can be used as a parameter to an OpenGL function expecting an array of float
double cryph::AffVector::dx |
double cryph::AffVector::dy |
double cryph::AffVector::dz |
The documentation for this class was generated from the following files: