4d point coordinates. More...
#include <dpoint4d.h>
Public Member Functions | |
void | Zero () |
zero out this point. More... | |
void | SetComponents (double xComponent, double yComponent, double zComponent, double wComponent) |
void | Init (DPoint3dCR source, double w) |
Fill a DPoint4d, using given xyz components and weight. More... | |
void | Init (double x, double y, double z, double w) |
Fill a DPoint4d, using given xyz components and weight. More... | |
void | InitFromArray (double *pArray) |
Copy 4 components (xyzw) from a double array into this instance. More... | |
void | GetComponents (double &xCoord, double &yCoord, double &zCoord, double &wCoord) const |
Copies component data out of this instance into doubles pXCoord, pYCoord, pZCoord and pWCoord. More... | |
void | SetComponent (double a, int index) |
Set x,y,z or w component of a point. More... | |
double | GetComponent (int index) const |
double | MagnitudeXYZW () const |
magnitude as pure 4d point – sqrt sum of squares. More... | |
double | DotProduct (DPoint4dCR point) const |
Return the full 4d (xyzw) dot product of two homogeneous points. More... | |
double | DotProductXY (DPoint4dCR point) const |
Return the dot product of only the xy parts of two homogeneous points. More... | |
double | DotProductXYZ (DPoint4dCR point2) const |
Return the xyz dot product of two homogeneous points, i.e. More... | |
double | DotProductXYW (DPoint4dCR point) const |
Return the xyz dot product of two homogeneous points, i.e. More... | |
double | DotProduct (double x, double y, double z, double w) const |
double | DotProduct (DPoint3dCR point2, double w) const |
double | EyePlaneTest (DPoint3dCR origin, DPoint3dCR normal) const |
Return the dot product of a plane normal and a vector 'to the eyepoint'. More... | |
double | RealDistance (DPoint4dCR vec2) const |
bool | RealDistanceSquaredXY (double *pDistanceSquared, DPoint3dCR vec2) const |
bool | RealDistanceXY (double &distance, DPoint4dCR pointB) const |
bool | RealDistanceSquared (double *pDistanceSquared, DPoint3dCR vec2) const |
bool | RealDistanceSquared (double *pDistanceSquared, DPoint4dCR vec2) const |
void | Interpolate (DPoint4dCR point0, double s, DPoint4dCR point1) |
Interpolates between two homogeneous vectors. More... | |
void | InitFrom (DPoint3dCR point, double w) |
Initializ a homogeneous point from a 3D point and separate weight. More... | |
void | GetXYZ (DPoint3dR point) const |
Copy the xyz components out of a homogeneous point. More... | |
void | GetXYW (DPoint3dR point) const |
Copy the xyw components out of a homogeneous point. More... | |
void | GetXYZ (DPoint3dR point, int xIndex, int yIndex, int zIndex) const |
Set components of a 3d point from 3 indices into a homogeneous point. More... | |
bool | PlaneFromOriginAndNormal (DPoint3dCR origin, DPoint3dCR normal) |
Computes the homogeneous vector for a plane defined by 3D origin and normal. More... | |
bool | PlaneFrom3Points (DPoint3dCR origin, DPoint3dCR point1, DPoint3dCR point2) |
Computes the homogeneous coordinate vector for a plane defined by 3 3D points. More... | |
bool | PlaneFromOriginAndVectors (DPoint4dCR origin, DPoint3dCR vector0, DPoint3dCR vector1) |
Computes the homogeneous coordinate vector for a plane defined by a DPoint4d origin and a pair of 3D vectors. More... | |
bool | OriginAndNormalFromPlane (DPoint3dR origin, DPoint3dR normal) const |
void | SumOf (DPoint4dCR pt1, DPoint4dCR pt2) |
Adds two homogeneous points. More... | |
void | WeightedDifferenceOf (DPoint4dCR A, DPoint4dCR B) |
Scale each point by the other's weight and return the difference. More... | |
void | WeightedDifferenceOf (DPoint4dCR A, DPoint3dCR B, double wB) |
Scale each point by the other's weight and return the difference. More... | |
void | WeightedDifferenceOf (DPoint3dCR A, double wA, DPoint4dCR B) |
Scale each point by the other's weight and return the difference. More... | |
void | Add (DPoint4dCR vector) |
Add a vector to the instance. More... | |
void | Subtract (DPoint4dCR vector) |
Subtract a vector from the instance. More... | |
void | DifferenceOf (DPoint4dCR point1, DPoint4dCR point2) |
Subtract second point from first. More... | |
void | SumOf (DPoint4dCR point0, DPoint4dCR point1, double scale1, DPoint4dCR point2, double scale2) |
Adds two homogeneous points to a base point. More... | |
void | SumOf (DPoint4dCR point1, double scale1, DPoint4dCR point2, double scale2) |
Adds two homogeneous points with scales. More... | |
void | SumOf (DPoint4dCR point0, DPoint4dCR point1, double scale1, DPoint4dCR point2, double scale2, DPoint4dCR point3, double scale3) |
Adds three homogeneous points to a base point. More... | |
void | SumOf (DPoint4dCR point1, double scale1, DPoint4dCR point2, double scale2, DPoint4dCR point3, double scale3) |
Adds three homogeneous points. More... | |
void | SumOf (DPoint4dCR point0, DPoint4dCR point1, double scale1) |
Adds two homogeneous points to a base point. More... | |
bool | GetProjectedXYZ (DPoint3dR rPoint) const |
Normalizes a homogeneous point (by dividing by w part.) More... | |
bool | InitWithNormalizedWeight (DPoint4dCR source) |
Initializes the instance by normalizing the weight of the source. More... | |
bool | NormalizeWeightInPlace () |
Divide through by weight component. More... | |
bool | NormalizePlaneOf (DPoint4dCR plane0) |
Normalizes a homogeneous plane (by dividing through by the vector magnitude). More... | |
void | Scale (DPoint4dCR point, double scale) |
sets pOutVec to pInVec*scale. More... | |
void | Scale (double scale) |
Scale a point in place. More... | |
void | Negate (DPoint4dCR point) |
Negate a point. More... | |
void | Negate () |
Negate all components of a point in place. More... | |
bool | IsEqual (DPoint4dCR vec2) const |
Exact equality test between points. More... | |
bool | IsEqual (DPoint4dCR vec2, double tolerance) const |
bool | IsEqual (DPoint4dCR vec2, double xyzTol, double wTol) const |
double | MaxAbs () const |
double | MaxAbsUnnormalizedXYZ () const |
double | MaxUnnormalizedXYZDiff (DPoint4dCR other) const |
double | GetRotationAngleAndVectorFromQuaternion (DPoint3dR axis) const |
Returns the angle of rotation represented by this instance quaternion and sets axis to be the normalized vector about which this instance rotates. More... | |
bool | IsDisconnect () const |
void | InitDisconnect () |
Initialize a point with all coordinates as the disconnect value. More... | |
Static Public Member Functions | |
static DPoint4d | From (double x, double y, double z, double w) |
Return point with direct initialization. More... | |
static DPoint4d | From (DPoint3dCR xyz, double w) |
Return point with direct initialization. More... | |
static DPoint4d | FromSumOf (DPoint4dCR xyzw0, double scale0, DPoint4dCR xyzw1, double scale1, DPoint4dCR xyzw2, double scale2) |
Return point with sum of scaled inputs. More... | |
static DPoint4d | FromMultiply (DMatrix4dCP matrix, DPoint3dCR point) |
Return product of 3d point with (possibly omitted) DMatrix4d. More... | |
static DPoint4d | FromMultiply (DMatrix4dCP matrix, DPoint4dCR point) |
Return product of 4d point with (possibly omitted!!) DMatrix4d. More... | |
static DPoint4d | FromInterpolate (DPoint4dCR point0, double s, DPoint4dCR point1) |
Interpolates between two homogeneous vectors. More... | |
static bool | AlmostEqual (bvector< DPoint4d > const &dataA, bvector< DPoint4d > const &dataB, double xyzTol, double wTol) |
test for nearly equal points in two arrays More... | |
static bool | AlmostEqualReversed (bvector< DPoint4d > const &dataA, bvector< DPoint4d > const &dataB, double xyzTol, double wTol) |
test for nearly equal points in two arrays, reversing the second More... | |
static bool | AlmostEqual (DPoint4dCP dataA, DPoint4dCP dataB, size_t n, double xyzTol, double wTol) |
test for nearly equal points in two arrays More... | |
static bool | AlmostEqualReversed (DPoint4dCP dataA, DPoint4dCP dataB, size_t n, double xyzTol, double wTol) |
test for nearly equal points in two arrays, reversing the second More... | |
static DPoint4d | FromCrossProduct (DPoint4dCR pointA, DPoint4dCR pointB, DPoint4dCR pointC) |
Return a point "perpendicular" to all 3 inputs. More... | |
static ValidatedDPlane3dByVectors | TryNormalizePointAndDerivatives (DPoint4dCR homogeneousPoint, DPoint4dCR homogeneousDerivative1, DPoint4dCR homogeneousDerivative2) |
Return point and vectors that are the cartesian image of a homoegneous point and derivatives ul> li>The return is marked invalid if weight is zero. More... | |
Public Attributes | |
double | x |
x coordinate More... | |
double | y |
y coordinate More... | |
double | z |
z coordinate More... | |
double | w |
w coordinate. 1 is a simple point. 0 is a vector. For other values, dividing through by w gives the simple point. More... | |
4d point coordinates.
void Add | ( | DPoint4dCR | vector | ) |
Add a vector to the instance.
[in] | vector | vector to add |
|
static |
test for nearly equal points in two arrays
[in] | dataA | first array |
[in] | dataB | second array |
[in] | xyzTol | tolerance for xyz parts |
[in] | wTol | tolerance for weights |
|
static |
test for nearly equal points in two arrays
[in] | dataA | first array |
[in] | dataB | second array |
[in] | n | number of points |
[in] | xyzTol | tolerance for xyz parts |
[in] | wTol | tolerance for weights |
|
static |
test for nearly equal points in two arrays, reversing the second
[in] | dataA | first array |
[in] | dataB | second array |
[in] | xyzTol | tolerance for xyz parts |
[in] | wTol | tolerance for weights |
|
static |
test for nearly equal points in two arrays, reversing the second
[in] | dataA | first array |
[in] | dataB | second array |
[in] | n | number of points |
[in] | xyzTol | tolerance for xyz parts |
[in] | wTol | tolerance for weights |
void DifferenceOf | ( | DPoint4dCR | point1, |
DPoint4dCR | point2 | ||
) |
Subtract second point from first.
[in] | point1 | first point |
[in] | point2 | second point |
double DotProduct | ( | DPoint4dCR | point | ) | const |
Return the full 4d (xyzw) dot product of two homogeneous points.
[in] | point | second point of dot product. |
double DotProduct | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) | const |
[in] | x | x component of second point |
[in] | y | y component of second point |
[in] | z | z component of second point |
[in] | w | w component of second point |
double DotProduct | ( | DPoint3dCR | point2, |
double | w | ||
) | const |
[in] | point2 | second point |
[in] | w | w component of second point |
double DotProductXY | ( | DPoint4dCR | point | ) | const |
Return the dot product of only the xy parts of two homogeneous points.
Ignore z, ignore w.
[in] | point | second point |
double DotProductXYW | ( | DPoint4dCR | point | ) | const |
Return the xyz dot product of two homogeneous points, i.e.
ignore z.
[in] | point | second second |
double DotProductXYZ | ( | DPoint4dCR | point2 | ) | const |
Return the xyz dot product of two homogeneous points, i.e.
ignore w.
[in] | point2 | second point of dot product. |
double EyePlaneTest | ( | DPoint3dCR | origin, |
DPoint3dCR | normal | ||
) | const |
Return the dot product of a plane normal and a vector 'to the eyepoint'.
The plane is given as cartesian origin and normal; the eye is given as homogeneous point, i.e. weight zero for flat view, nonzero for perspective. Eyepoints constucted 'by hand' usually look like this: Flat view "from infinity" looking in direction (xyz): eyepoint = (x,y,z,0) i.e. a top view has eyepoint (0,0,1,0) Perspective from eyepoint at (x,y,z): eyepoint (x,y,z,1) When viewing is constructed by a sequence of homogeneous transformations, with the final (device) projection to the xy plane, the (pretransform) eyepoint is 'by definition' Tinverse * (0,0,1,0)' i.e column 2 (zero based) of the composite viewing transform. (Note that the weight part can be nonzero.)
[in] | origin | any cartesian point on plane |
[in] | normal | cartesian plane normal |
|
static |
Return point with direct initialization.
[in] | x | x coordinate |
[in] | y | y coordinate |
[in] | z | z coordinate |
[in] | w | w coordinate |
|
static |
Return point with direct initialization.
[in] | xyz | x,y,z coordinates |
[in] | w | coordinate |
|
static |
Return a point "perpendicular" to all 3 inputs.
|
static |
Interpolates between two homogeneous vectors.
|
[in] | point0 | s=0 point |
[in] | s | interpolation parameter |
[in] | point1 | s=1 point |
|
static |
Return product of 3d point with (possibly omitted) DMatrix4d.
[in] | matrix | if missing, identity matrix is implied. |
[in] | point | 3d point. |
|
static |
Return product of 4d point with (possibly omitted!!) DMatrix4d.
[in] | matrix | if missing, identity matrix is implied. |
[in] | point | 3d point. |
|
static |
Return point with sum of scaled inputs.
double GetComponent | ( | int | index | ) | const |
[in] | index | 0=x, 1=y, 2=z, 3=w, others cyclic |
void GetComponents | ( | double & | xCoord, |
double & | yCoord, | ||
double & | zCoord, | ||
double & | wCoord | ||
) | const |
Copies component data out of this instance into doubles pXCoord, pYCoord, pZCoord and pWCoord.
[out] | xCoord | x component |
[out] | yCoord | y component |
[out] | zCoord | z component |
[out] | wCoord | w component |
bool GetProjectedXYZ | ( | DPoint3dR | rPoint | ) | const |
Normalizes a homogeneous point (by dividing by w part.)
[out] | rPoint | normalized point |
double GetRotationAngleAndVectorFromQuaternion | ( | DPoint3dR | axis | ) | const |
Returns the angle of rotation represented by this instance quaternion and sets axis to be the normalized vector about which this instance rotates.
The instance is assumed to be a normalized quaternion, i.e. of the form (x,y,z,w) where
x*x + y*y + z*z + w*w = 1.
The angle is returned within the closed interval [0,Pi].
[out] | axis | normalized axis of rotation |
void GetXYW | ( | DPoint3dR | point | ) | const |
Copy the xyw components out of a homogeneous point.
The z component not referenced. This is a copy, not a normalization.
[out] | point | xyw parts copied to xyz |
void GetXYZ | ( | DPoint3dR | point | ) | const |
Copy the xyz components out of a homogeneous point.
The weight is not referenced, i.e. the xyz components are NOT normalized.
[out] | point | cartesian point |
void GetXYZ | ( | DPoint3dR | point, |
int | xIndex, | ||
int | yIndex, | ||
int | zIndex | ||
) | const |
Set components of a 3d point from 3 indices into a homogeneous point.
Indices are interpreted cyclically.
[out] | point | output point |
[in] | xIndex | index for x component of output |
[in] | yIndex | index for y component of output |
[in] | zIndex | index for z component of output |
void Init | ( | DPoint3dCR | source, |
double | w | ||
) |
Fill a DPoint4d, using given xyz components and weight.
All components are copied in directly – the xyz components are not multiplied by the weight.
[in] | source | xyz components |
[in] | w | w component |
void Init | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) |
Fill a DPoint4d, using given xyz components and weight.
All components are copied in directly – the xyz components are not multiplied by the weight.
[in] | x | x component |
[in] | y | y component |
[in] | z | z component |
[in] | x | x component |
[in] | w | z coordinate |
void InitDisconnect | ( | ) |
Initialize a point with all coordinates as the disconnect value.
void InitFrom | ( | DPoint3dCR | point, |
double | w | ||
) |
Initializ a homogeneous point from a 3D point and separate weight.
NOTE The xyz components copied unchanged, i.e. not multiplied by the weight.
[in] | point | cartesian point |
[in] | w | weight component |
void InitFromArray | ( | double * | pArray | ) |
Copy 4 components (xyzw) from a double array into this instance.
[in] | pArray | array of doubles |
bool InitWithNormalizedWeight | ( | DPoint4dCR | source | ) |
Initializes the instance by normalizing the weight of the source.
void Interpolate | ( | DPoint4dCR | point0, |
double | s, | ||
DPoint4dCR | point1 | ||
) |
Interpolates between two homogeneous vectors.
|
[in] | point0 | s=0 point |
[in] | s | interpolation parameter |
[in] | point1 | s=1 point |
bool IsDisconnect | ( | ) | const |
bool IsEqual | ( | DPoint4dCR | vec2 | ) | const |
Exact equality test between points.
(Also see method with same name but added tolerance argument.)
[in] | vec2 | vector |
bool IsEqual | ( | DPoint4dCR | vec2, |
double | tolerance | ||
) | const |
[in] | vec2 | vector |
[in] | tolerance | tolerance |
bool IsEqual | ( | DPoint4dCR | vec2, |
double | xyzTol, | ||
double | wTol | ||
) | const |
[in] | vec2 | vector |
[in] | xyzTol | tolerance for absolute difference between x,y,z components. |
[in] | wTol | tolerance for absolute difference between w components. |
double MagnitudeXYZW | ( | ) | const |
magnitude as pure 4d point – sqrt sum of squares.
double MaxAbs | ( | ) | const |
double MaxAbsUnnormalizedXYZ | ( | ) | const |
double MaxUnnormalizedXYZDiff | ( | DPoint4dCR | other | ) | const |
void Negate | ( | DPoint4dCR | point | ) |
Negate a point.
[in] | point | input point |
void Negate | ( | ) |
Negate all components of a point in place.
bool NormalizePlaneOf | ( | DPoint4dCR | plane0 | ) |
Normalizes a homogeneous plane (by dividing through by the vector magnitude).
[in] | plane0 | homogeneous plane |
bool NormalizeWeightInPlace | ( | ) |
Divide through by weight component.
bool OriginAndNormalFromPlane | ( | DPoint3dR | origin, |
DPoint3dR | normal | ||
) | const |
[out] | origin | cartesian orign |
[out] | normal | cartesian normal |
bool PlaneFrom3Points | ( | DPoint3dCR | origin, |
DPoint3dCR | point1, | ||
DPoint3dCR | point2 | ||
) |
Computes the homogeneous coordinate vector for a plane defined by 3 3D points.
[out] | origin | origin point |
[out] | point1 | another point on plane |
[out] | point2 | another point on plane |
bool PlaneFromOriginAndNormal | ( | DPoint3dCR | origin, |
DPoint3dCR | normal | ||
) |
Computes the homogeneous vector for a plane defined by 3D origin and normal.
NOTE If the normal vector is null, a 0000 vector is returned.
[out] | origin | origin point |
[out] | normal | normal vector |
bool PlaneFromOriginAndVectors | ( | DPoint4dCR | origin, |
DPoint3dCR | vector0, | ||
DPoint3dCR | vector1 | ||
) |
Computes the homogeneous coordinate vector for a plane defined by a DPoint4d origin and a pair of 3D vectors.
[out] | origin | a point on the plane. |
[out] | vector0 | a vector in the plane. |
[out] | vector1 | another vector in the plane. |
double RealDistance | ( | DPoint4dCR | vec2 | ) | const |
[in] | vec2 | second point |
bool RealDistanceSquared | ( | double * | pDistanceSquared, |
DPoint3dCR | vec2 | ||
) | const |
[out] | pDistanceSquared | squared distance |
[in] | vec2 | second point |
bool RealDistanceSquared | ( | double * | pDistanceSquared, |
DPoint4dCR | vec2 | ||
) | const |
[out] | pDistanceSquared | squared distance |
[in] | vec2 | second point |
bool RealDistanceSquaredXY | ( | double * | pDistanceSquared, |
DPoint3dCR | vec2 | ||
) | const |
[out] | pDistanceSquared | squared distance |
[in] | vec2 | second point |
bool RealDistanceXY | ( | double & | distance, |
DPoint4dCR | pointB | ||
) | const |
[out] | distance | distance between xy parts |
[in] | pointB | other point. |
void Scale | ( | DPoint4dCR | point, |
double | scale | ||
) |
sets pOutVec to pInVec*scale.
[in] | point | input vector |
[in] | scale | scale |
void Scale | ( | double | scale | ) |
Scale a point in place.
[in] | scale | scale factor |
void SetComponent | ( | double | a, |
int | index | ||
) |
Set x,y,z or w component of a point.
[in] | a | component value |
[in] | index | 0=x, 1=y, 2=z, 3=w, others cyclic |
void SetComponents | ( | double | xComponent, |
double | yComponent, | ||
double | zComponent, | ||
double | wComponent | ||
) |
[in] | xComponent | x component |
[in] | yComponent | y component |
[in] | zComponent | z component |
[in] | wComponent | w component |
void Subtract | ( | DPoint4dCR | vector | ) |
Subtract a vector from the instance.
[in] | vector | vector to subtract |
void SumOf | ( | DPoint4dCR | pt1, |
DPoint4dCR | pt2 | ||
) |
Adds two homogeneous points.
[in] | pt1 | point 1 |
[in] | pt2 | point 2 |
void SumOf | ( | DPoint4dCR | point0, |
DPoint4dCR | point1, | ||
double | scale1, | ||
DPoint4dCR | point2, | ||
double | scale2 | ||
) |
Adds two homogeneous points to a base point.
[in] | point0 | base point |
[in] | point1 | point 1 |
[in] | scale1 | scale factor for point 1 |
[in] | point2 | point 2 |
[in] | scale2 | scale factor for point 2 |
void SumOf | ( | DPoint4dCR | point1, |
double | scale1, | ||
DPoint4dCR | point2, | ||
double | scale2 | ||
) |
Adds two homogeneous points with scales.
[in] | point1 | point 1 |
[in] | scale1 | scale factor for point 1 |
[in] | point2 | point 2 |
[in] | scale2 | scale factor for point 2 |
void SumOf | ( | DPoint4dCR | point0, |
DPoint4dCR | point1, | ||
double | scale1, | ||
DPoint4dCR | point2, | ||
double | scale2, | ||
DPoint4dCR | point3, | ||
double | scale3 | ||
) |
Adds three homogeneous points to a base point.
[in] | point0 | base point |
[in] | point1 | point 1 |
[in] | scale1 | scale factor for point 1 |
[in] | point2 | point 2 |
[in] | scale2 | scale factor for point 2 |
[in] | point3 | point 3 |
[in] | scale3 | scale factor for point 3 |
void SumOf | ( | DPoint4dCR | point1, |
double | scale1, | ||
DPoint4dCR | point2, | ||
double | scale2, | ||
DPoint4dCR | point3, | ||
double | scale3 | ||
) |
Adds three homogeneous points.
[in] | point1 | point 1 |
[in] | scale1 | scale factor for point 1 |
[in] | point2 | point 2 |
[in] | scale2 | scale factor for point 2 |
[in] | point3 | point 3 |
[in] | scale3 | scale factor for point 3 |
void SumOf | ( | DPoint4dCR | point0, |
DPoint4dCR | point1, | ||
double | scale1 | ||
) |
Adds two homogeneous points to a base point.
[in] | point0 | base point |
[in] | point1 | point 1 |
[in] | scale1 | scale factor for point 1 |
|
static |
Return point and vectors that are the cartesian image of a homoegneous point and derivatives ul> li>The return is marked invalid if weight is zero.
/ul>
[in] | homogeneousPoint | weighted point |
[in] | homogeneousDerivative1 | weighted first derivative |
[in] | homogeneousDerivative2 | weighted second derivative |
void WeightedDifferenceOf | ( | DPoint4dCR | A, |
DPoint4dCR | B | ||
) |
Scale each point by the other's weight and return the difference.
void WeightedDifferenceOf | ( | DPoint4dCR | A, |
DPoint3dCR | B, | ||
double | wB | ||
) |
Scale each point by the other's weight and return the difference.
(Note that the w component of the result is always zero)
void WeightedDifferenceOf | ( | DPoint3dCR | A, |
double | wA, | ||
DPoint4dCR | B | ||
) |
Scale each point by the other's weight and return the difference.
(Note that the w component of the result is always zero)
void Zero | ( | ) |
zero out this point.
double w |
w coordinate. 1 is a simple point. 0 is a vector. For other values, dividing through by w gives the simple point.
double x |
x coordinate
double y |
y coordinate
double z |
z coordinate