cryph utilities [subset]  2.0
Subset of the full cryph package of mathematical utilities for points, vectors, and matrices
Public Member Functions | Public Attributes | List of all members
cryph::ProjPoint Class Reference

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
 

Constructor & Destructor Documentation

cryph::ProjPoint::ProjPoint ( )

Default constructor creates ProjPoint (0,0,0,1)

cryph::ProjPoint::ProjPoint ( const ProjPoint p)

The copy constructor.

Parameters
pthe 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).

Parameters
pan affine point'
wthe 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

Parameters
passumed 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

Parameters
passumed 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.

Parameters
xxthe affine x coordinate already multiplied by w
yythe affine y coordinate already multiplied by w
zzthe affine z coordinate already multiplied by w
wwthe w coordinate
cryph::ProjPoint::~ProjPoint ( )
virtual

The destructor.

Member Function Documentation

double * cryph::ProjPoint::aCoords ( double  coords[],
int  offset = 0 
) const

Return the affine coordinates of this ProjPoint in the given array

Parameters
coordsan array of doubles to hold the 3 affine coordinates (must be at least length offset+3.
offsetthe starting location in coords where the 3 affine coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of double.
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.)

Parameters
coordsan array of double[3] to hold the 3 affine coordinates The first dimension must be at least offset+1.
offsetthe starting location in coords where the 3 affine coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of "dvec3".
float * cryph::ProjPoint::aCoords ( float  coords[],
int  offset = 0 
) const

Return the affine coordinates of this ProjPoint in the given array

Parameters
coordsan array of float to hold the 3 affine coordinates (must be at least length offset+3.
offsetthe starting location in coords where the 3 affine coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of float.
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.)

Parameters
coordsan array of float[3] to hold the 3 affine coordinates The first dimension must be at least offset+1.
offsetthe starting location in coords where the 3 affine coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of "vec3".
void cryph::ProjPoint::aCoords ( AffPoint aPnt) const
inline

Fetch the affine coordinates of the point corresponding to this ProjPoint instance into the given AffPoint instance.

Parameters
aPntthe AfPoint into which the projected point is to be written.
AffPoint cryph::ProjPoint::aCoords ( ) const
inline

Return an AffPoint holding the projected coordinates of this ProjPoint.

Returns
the projected AffPoint.
ProjPoint cryph::ProjPoint::operator* ( double  f) const
inline

Return the scalar product of "this" ProjPoint and a scalar, leaving "this" point unchanged.

Parameters
fthe scalar
Returns
the product: f*this
ProjPoint cryph::ProjPoint::operator*= ( double  f)

The *= operator for scalar multiplication

Parameters
fthe scalar to be used to multiply all 4 coordinates of "this".
Returns
"this" ProjPoint
ProjPoint cryph::ProjPoint::operator+ ( const ProjPoint p2) const
inline

Return the sum of "this" point and another, leaving "this" point unchanged.

Parameters
p2the second point to be summed
Returns
the sum
ProjPoint cryph::ProjPoint::operator+= ( const ProjPoint rhs)

The += operator

Parameters
rhsthe projective space point to be accumulated into "this".
Returns
"this" ProjPoint
ProjPoint cryph::ProjPoint::operator- ( const ProjPoint p2) const
inline

Return the difference between "this" point and another, leaving "this" point unchanged.

Parameters
p2the point to be subtracted from "this".
Returns
the difference
ProjPoint cryph::ProjPoint::operator/ ( double  f) const
inline

Return the quotient of "this" ProjPoint and a scalar, leaving "this" ProjPoint unchanged.

Parameters
fthe scalar
Returns
the quotient: this/f
ProjPoint cryph::ProjPoint::operator/= ( double  f)

The /= operator for scalar division

Parameters
fthe scalar to be used to divide into all 4 coordinates of "this".
Returns
"this" ProjPoint
ProjPoint cryph::ProjPoint::operator= ( const ProjPoint rhs)

The assignment operator

Parameters
rhsthe projective space point to be assigned to "this".
Returns
"this" ProjPoint
double cryph::ProjPoint::operator[] ( int  index) const

Read-only indexing

Parameters
index0 <= index <= 3 (0: x; 1: y: 2: z; 3: w)
Returns
the requested coordinate
See also
AffPoint where indexing constants are defined
double * cryph::ProjPoint::pCoords ( double *  coords,
int  offset = 0 
) const

Return the projective coordinates of this ProjPoint in the given array

Parameters
coordsan array of doubles to hold the 4 projective space coordinates (must be at least length offset+4.
offsetthe starting location in coords where the 4 projective space coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of double.
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.)

Parameters
coordsan array of double[4] to hold the 4 projective space coordinates. The first dimension must be at least offset+1.
offsetthe starting location in coords where the 4 projective space coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of "dvec4".
float * cryph::ProjPoint::pCoords ( float *  coords,
int  offset = 0 
) const

Return the projective coordinates of this ProjPoint in the given array

Parameters
coordsan array of float to hold the 4 projective space coordinates (must be at least length offset+4.
offsetthe starting location in coords where the 4 projective space coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of float.
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.)

Parameters
coordsan array of float[4] to hold the 4 projective space coordinates. The first dimension must be at least offset+1.
offsetthe starting location in coords where the 4 projective space coordinates are to be written.
Returns
the base address of the given "coords" array so that this method call can be used as a parameter to a function expecting an array of "vec4".
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)
Parameters
xyz[INPUT ONLY] an array of char of length 4 interpreted as explained and illustrated above

Member Data Documentation

double cryph::ProjPoint::w

w coordinate

double cryph::ProjPoint::x

x coordinate

double cryph::ProjPoint::y

y coordinate

double cryph::ProjPoint::z

z coordinate


The documentation for this class was generated from the following files: