cryph utilities [subset]
2.0
Subset of the full cryph package of mathematical utilities for points, vectors, and matrices
|
Public Member Functions | |
ProjPoint () | |
ProjPoint (const ProjPoint &p) | |
ProjPoint (const AffPoint &p, double w=1.0) | |
ProjPoint (const double *p) | |
ProjPoint (const float *p) | |
ProjPoint (double xx, double yy, double zz=0.0, double ww=1.0) | |
virtual | ~ProjPoint () |
ProjPoint | operator= (const ProjPoint &rhs) |
ProjPoint | operator+= (const ProjPoint &rhs) |
ProjPoint | operator*= (double f) |
ProjPoint | operator/= (double f) |
double | operator[] (int index) const |
ProjPoint | operator+ (const ProjPoint &p2) const |
ProjPoint | operator- (const ProjPoint &p2) const |
ProjPoint | operator* (double f) const |
ProjPoint | operator/ (double f) const |
double * | aCoords (double coords[], int offset=0) const |
double * | aCoords (double coords[][3], int offset=0) const |
float * | aCoords (float coords[], int offset=0) const |
float * | aCoords (float coords[][3], int offset=0) const |
void | aCoords (AffPoint &aPnt) const |
AffPoint | aCoords () const |
double * | pCoords (double *coords, int offset=0) const |
double * | pCoords (double coords[][4], int offset=0) const |
float * | pCoords (float *coords, int offset=0) const |
float * | pCoords (float coords[][4], int offset=0) const |
void | swizzle (char xyzw[4]) |
Public Attributes | |
double | x |
double | y |
double | z |
double | w |
cryph::ProjPoint::ProjPoint | ( | ) |
Default constructor creates ProjPoint (0,0,0,1)
cryph::ProjPoint::ProjPoint | ( | const ProjPoint & | p | ) |
The copy constructor.
p | the ProjPoint whose coordinates are used to initialize "this". |
cryph::ProjPoint::ProjPoint | ( | const AffPoint & | p, |
double | w = 1.0 |
||
) |
Construct a projective space point from an affine point an an explicit w. The constructed point will be (w*p.x, w*p.y, w*p.z, w).
p | an affine point' |
w | the w plane of projective space onto which p is to be projected. |
cryph::ProjPoint::ProjPoint | ( | const double * | p | ) |
Construct a projective space point using 4 double precision coordinates in the given array
p | assumed to be a double precision array of length 4 holding the coordinates of a point in projective space. |
cryph::ProjPoint::ProjPoint | ( | const float * | p | ) |
Construct a projective space point using 4 single precision coordinates in the given array
p | assumed to be a single precision array of length 4 holding the coordinates of a point in projective space. |
cryph::ProjPoint::ProjPoint | ( | double | xx, |
double | yy, | ||
double | zz = 0.0 , |
||
double | ww = 1.0 |
||
) |
Construct a projective space point from the given 4 coordinates. The coordinates are assumed to be already embedded in projective space.
xx | the affine x coordinate already multiplied by w |
yy | the affine y coordinate already multiplied by w |
zz | the affine z coordinate already multiplied by w |
ww | the w coordinate |
|
virtual |
The destructor.
double * cryph::ProjPoint::aCoords | ( | double | coords[], |
int | offset = 0 |
||
) | const |
Return the affine coordinates of this ProjPoint in the given array
coords | an array of doubles to hold the 3 affine coordinates (must be at least length offset+3. |
offset | the starting location in coords where the 3 affine coordinates are to be written. |
double * cryph::ProjPoint::aCoords | ( | double | coords[][3], |
int | offset = 0 |
||
) | const |
Return the affine coordinates of this ProjPoint in the given array of 3-element values. (Mimics an OpenGL GLSL array of dvec3.)
coords | an array of double[3] to hold the 3 affine coordinates The first dimension must be at least offset+1. |
offset | the starting location in coords where the 3 affine coordinates are to be written. |
float * cryph::ProjPoint::aCoords | ( | float | coords[], |
int | offset = 0 |
||
) | const |
Return the affine coordinates of this ProjPoint in the given array
coords | an array of float to hold the 3 affine coordinates (must be at least length offset+3. |
offset | the starting location in coords where the 3 affine coordinates are to be written. |
float * cryph::ProjPoint::aCoords | ( | float | coords[][3], |
int | offset = 0 |
||
) | const |
Return the affine coordinates of this ProjPoint in the given array of 3-element values. (Mimics an OpenGL GLSL array of vec3.)
coords | an array of float[3] to hold the 3 affine coordinates The first dimension must be at least offset+1. |
offset | the starting location in coords where the 3 affine coordinates are to be written. |
|
inline |
|
inline |
|
inline |
Return the scalar product of "this" ProjPoint and a scalar, leaving "this" point unchanged.
f | the scalar |
ProjPoint cryph::ProjPoint::operator*= | ( | double | f | ) |
The *= operator for scalar multiplication
f | the scalar to be used to multiply all 4 coordinates of "this". |
Return the sum of "this" point and another, leaving "this" point unchanged.
p2 | the second point to be summed |
The += operator
rhs | the projective space point to be accumulated into "this". |
Return the difference between "this" point and another, leaving "this" point unchanged.
p2 | the point to be subtracted from "this". |
|
inline |
ProjPoint cryph::ProjPoint::operator/= | ( | double | f | ) |
The /= operator for scalar division
f | the scalar to be used to divide into all 4 coordinates of "this". |
The assignment operator
rhs | the projective space point to be assigned to "this". |
double cryph::ProjPoint::operator[] | ( | int | index | ) | const |
Read-only indexing
index | 0 <= index <= 3 (0: x; 1: y: 2: z; 3: w) |
double * cryph::ProjPoint::pCoords | ( | double * | coords, |
int | offset = 0 |
||
) | const |
Return the projective coordinates of this ProjPoint in the given array
coords | an array of doubles to hold the 4 projective space coordinates (must be at least length offset+4. |
offset | the starting location in coords where the 4 projective space coordinates are to be written. |
double * cryph::ProjPoint::pCoords | ( | double | coords[][4], |
int | offset = 0 |
||
) | const |
Return the projective space coordinates of this ProjPoint in the given array of 4-element values. (Mimics an OpenGL GLSL array of dvec4.)
coords | an array of double[4] to hold the 4 projective space coordinates. The first dimension must be at least offset+1. |
offset | the starting location in coords where the 4 projective space coordinates are to be written. |
float * cryph::ProjPoint::pCoords | ( | float * | coords, |
int | offset = 0 |
||
) | const |
Return the projective coordinates of this ProjPoint in the given array
coords | an array of float to hold the 4 projective space coordinates (must be at least length offset+4. |
offset | the starting location in coords where the 4 projective space coordinates are to be written. |
float * cryph::ProjPoint::pCoords | ( | float | coords[][4], |
int | offset = 0 |
||
) | const |
Return the projective space coordinates of this ProjPoint in the given array of 4-element values. (Mimics an OpenGL GLSL array of vec4.)
coords | an array of float[4] to hold the 4 projective space coordinates. The first dimension must be at least offset+1. |
offset | the starting location in coords where the 4 projective space coordinates are to be written. |
void cryph::ProjPoint::swizzle | ( | char | xyzw[4] | ) |
A method inspired by OpenGL's GLSL's swizzle operation. If the i-th character of xyzw is 'x', then the x coordinate of "this" point is placed into the i-th component of "this" point. If instead it is 'X', then negative of the x coordinate of "this" point is placed into the i-th component of "this" point. Characters 'y', 'Y', 'z', 'Z', 'w', 'W' behave similarly. Any other character is simply ignored. Some examples:
cryph::ProjPoint pp(4.0, 5.0, 6.0, 1.0); pp.swizzle("Zxy "); // pp is now (-6.0, 4.0, 5.0, 1.0) pp.swizzle("dzyw"); // pp is now (-6.0, 5.0, 4.0, 1.0) pp.swizzle("xxyw"); // pp is now (-6.0, -6.0, 5.0, 1.0)
xyz | [INPUT ONLY] an array of char of length 4 interpreted as explained and illustrated above |
double cryph::ProjPoint::w |
w coordinate
double cryph::ProjPoint::x |
x coordinate
double cryph::ProjPoint::y |
y coordinate
double cryph::ProjPoint::z |
z coordinate