Public Member Functions | Static Public Member Functions | List of all members

Vector with x,y,z components. More...

#include <dvec3d.h>

Inheritance diagram for DVec3d:
DPoint3d

Public Member Functions

void InitFromArray (double const *pXyz)
 Copies doubles from a 3 component array to the x,y, and z components of a DVec3d. More...
 
void Init (double ax, double ay, double az)
 Sets the x,y, and z components of a vector. More...
 
void Init (double ax, double ay)
 Sets the x, and y components of a vector. More...
 
void Init (DPoint3dCR point)
 Initialize a vector from a point (treating the point as a vector from its origin). More...
 
double Normalize (DVec3dCR vector)
 Normalizes (scales) a vector to length 1. More...
 
bool TryNormalize (DVec3dCR source, double &magnitude)
 initialize this vector to unit vector in the direction of source. More...
 
ValidatedDVec3d ValidatedNormalize () const
 return a (possibly invalid) unit vector in the direction of the calling instance. More...
 
double Normalize ()
 Replaces a vector by a unit vector in the same direction, and returns the original length. More...
 
double ScaleToLength (DVec3dCR vector, double length)
 Scales a vector to specified length. More...
 
double ScaleToLength (double length)
 Scales a vector to a specified length, and returns the prior length. More...
 
double NormalizedDifference (DPoint3dCR target, DPoint3dCR origin)
 Computes a unit vector in the direction of the difference of the vectors or vectors (Second parameter vector is subtracted from the first parameter vector, exactly as in the subtract function.) More...
 
void DifferenceOf (DVec3dCR vector1, DVec3dCR vector2)
 Subtract coordinates of two vectors. More...
 
void DifferenceOf (DPoint3dCR target, DPoint3dCR base)
 Subtract coordinates of two points. More...
 
void Subtract (DVec3dCR vector2)
 Subtract two vectors, and return the result in place of the first. More...
 
void InitFromXYAngleAndMagnitude (double theta, double magnitude)
 Sets a vector from given angle and distance in xy plane. More...
 
void InitFromColumn (RotMatrixCR matrix, int col)
 Extracts a column of a matrix. More...
 
void InitFromRow (RotMatrixCR matrix, int row)
 Extracts a row of a matrix. More...
 
void Multiply (RotMatrixCR matrix, DVec3dCR vector)
 Returns the product of a matrix times a vector. More...
 
void MultiplyTranspose (RotMatrixCR matrix, DVec3dCR vector)
 Returns the product of a matrix transpose times a vector. More...
 
void Multiply (RotMatrixCR matrix, double x, double y, double z)
 Returns the product of a matrix times a vector, with the vector given as separate components. More...
 
void MultiplyTranspose (RotMatrixCR matrix, double x, double y, double z)
 Returns the product P = [x,y,z]*M where M is the input matrix and P is the product vector. More...
 
void XyzOf (DPoint4dCR hPoint)
 Sets the x,y, and z components of a DVec3d structure from the corresponding parts of a DPoint4d. More...
 
void CrossProduct (DVec3dCR vector1, DVec3dCR vector2)
 Returns the (vector) cross product of two vectors. More...
 
void CrossProduct (DVec3dCR vector1, DPoint3dCR point2)
 Returns the (vector) cross product of two vectors. More...
 
void CrossProduct (DPoint3dCR point1, DVec3dCR vector2)
 Returns the (vector) cross product of two vectors. More...
 
void CrossProductToPoints (DPoint3dCR origin, DPoint3dCR target1, DPoint3dCR target2)
 Sets the instance to the (vector) cross product of two vectors. More...
 
double NormalizedCrossProduct (DVec3dCR vector1, DVec3dCR vector2)
 Compute the normalized cross product of two vectors and return the length of the unnormalized cross product. More...
 
double SizedCrossProduct (DVec3dCR vector1, DVec3dCR vector2, double productLength)
 Computes the cross product of the two parameter vectors and scales it to a given length. More...
 
double GeometricMeanCrossProduct (DVec3dCR vector1, DVec3dCR vector2)
 Computes the cross product of two vectors and scales it to the geometric mean of the lengths of the two vectors. More...
 
void RotateXY (DVec3dCR vector, double theta)
 Rotate a vector around the z axis. More...
 
void RotateXY (double theta)
 Rotate a vector around the z axis. More...
 
bool UnitPerpendicularXY (DVec3dCR vector)
 Compute a unit vector perpendicular to the xy parts of given vector. More...
 
void Interpolate (DVec3dCR vector0, double fractionParameter, DVec3dCR vector1)
 Computes a vector whose position is given by a fractional argument and two vectors. More...
 
void SumOf (DVec3dCR vector1, DVec3dCR vector2)
 Compute the sum of two vectors. More...
 
void Add (DVec3dCR vector)
 Adds a vector to a pointer or vector, returns the result in place. More...
 
void SumOf (DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2)
 Compute the sum of two vectors with scale factors. More...
 
void SumOf (DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2, DVec3dCR vector3, double scale3)
 Compute the sum of three vectors with scale factors. More...
 
void SumOf (DVec3dCR origin, DVec3dCR vector, double scale)
 Adds an origin and a scaled vector. More...
 
void SumOf (DVec3dCR origin, DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2)
 Adds an origin and two scaled vectors. More...
 
void SumOf (DVec3dCR origin, DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2, DVec3dCR vector3, double scale3)
 Adds an origin and three scaled vectors. More...
 
void Scale (DVec3dCR vector, double scale)
 Multiplies a vector by a scale factor. More...
 
void Scale (double scale)
 Multiplies a vector (in place) by a scale factor. More...
 
bool SafeDivide (DVec3dCR vector, double denominator)
 Try to divide each component of a vector by a scalar. More...
 
void Negate (DVec3dCR vector)
 Computes a negated (opposite) vector. More...
 
void Negate ()
 Negate a vector in place. More...
 
void WeightedDifferenceOf (DPoint4dCR hPoint1, DPoint4dCR hPoint2)
 Scale each (homogeneous) point by the other's weight and subtract, i.e. More...
 
void WeightedDifferenceCrossProduct (DPoint4dCR basePoint, DPoint4dCR target1, DPoint4dCR target2)
 Form the cross product of the weighted differences from base poitn to two targets. More...
 
double DotProduct (DVec3dCR vector2) const
 Returns the (scalar) dot product of two vectors. More...
 
double DotProductXY (DVec3dCR vector2) const
 Returns the (scalar) dot product of xy parts of two vectors. More...
 
double DotProduct (double ax, double ay, double az) const
 Computes the dot product of one vector given as a vector structure and another given as xyz components. More...
 
double DotProduct (DPoint3dCR point2) const
 Returns the (scalar) dot product of two vectors. More...
 
double DotProductRow (RotMatrixCR matrix, int index) const
 Returns the (scalar) dot product of this vector and a row of a matrix. More...
 
double DotProductColumn (RotMatrixCR matrix, int index) const
 Returns the (scalar) dot product of this vector and a column of a matrix. More...
 
double DotProductMatrixRow (TransformCR matrix, int index) const
 Returns the (scalar) dot product of this vector and a row of the matrix part of the transform. More...
 
double DotProductMatrixColumn (TransformCR matrix, int index) const
 Returns the (scalar) dot product of this vector and a column of the matrix part of the transform. More...
 
double TripleProduct (DVec3dCR vector2, DVec3dCR vector3) const
 Computes the triple product of three vectors. More...
 
double Magnitude () const
 Computes the magnitude of a vector. More...
 
double MagnitudeSquared () const
 Computes the squared magnitude of a vector. More...
 
double SafeOneOverMagnitudeSquared (double defaultValue) const
 Returns 1 over the squared magnitude, or caller supplied default if squared magnitude is too small. More...
 
ValidatedDouble ValidatedFractionOfProjection (DVec3dCR vectorToProject, double defaultValue=0.0) const
 Returns fraction at which other projects onto this, in ValidatedDouble which records if the division was safe. More...
 
double MagnitudeXY () const
 Computes the magnitude of the xy part of a vector. More...
 
double MagnitudeSquaredXY () const
 Computes the squared magnitude of the xy part of a vector. More...
 
double MaxAbs () const
 Finds the largest absolute value among the components of a vector. More...
 
double Distance (DVec3dCR vector2) const
 Computes the (cartesian) distance between two vectors. More...
 
double DistanceSquared (DVec3dCR vector2) const
 Computes the squared distance between two vectors. More...
 
double DistanceSquaredXY (DVec3dCR vector2) const
 Computes the squared distance between two vectors, using only the xy parts. More...
 
double DistanceXY (DVec3dCR vector2) const
 Computes the distance between two vectors, using only x and y components. More...
 
double CrossProductMagnitude (DVec3dCR other) const
 Compute the cross product with other and return is magnitude (but the cross product is not returned) More...
 
double CrossProductXY (DVec3dCR vector2) const
 Return the (scalar) cross product of the xy parts of two vectors. More...
 
void SetComponent (double a, int index)
 Set one of three components (x,y,z) of the vector. More...
 
double GetComponent (int index) const
 Gets a single component of a vector. More...
 
void GetComponents (double &xCoord, double &yCoord, double &zCoord) const
 Copies x,y,z components from a vector to individual variables. More...
 
bool GetTriad (DVec3dR xAxis, DVec3dR yAxis, DVec3dR zAxis) const
 Sets three vectors so that they are mutually perpendicular, the third (Z) vector is identical to the given axis vector, and all have the same length. More...
 
bool GetNormalizedTriad (DVec3dR xAxis, DVec3dR yAxis, DVec3dR zAxis) const
 Sets three vectors so that they are mutually perpendicular unit vectors with the third (Z) vector in the direction of the given axis vector. More...
 
bool ProjectToVector (DVec3dCR targetVector, double &fraction) const
 Find the fraction at which the instance projects to a vector. More...
 
bool ProjectToPlane (DVec3dCR vectorU, DVec3dCR vectorV, DPoint2dR uv) const
 Find the projection of the instance vector to a plane defined by two vectors. More...
 
bool GetPerpendicularParts (DVec3dCR hypotenuse, double &fraction, DVec3dR parallelPart, DVec3dR perpendicularPart) const
 Decompose hypotenuse into a vector parallel to the instance and a vector perpendicular to the instance. More...
 
double AngleTo (DVec3dCR vector2) const
 Returns the angle between two vectors. More...
 
double AngleToXY (DVec3dCR vector2) const
 Returns the angle from Vector1 to Vector2 using only xy parts. More...
 
double SmallerUnorientedAngleTo (DVec3dCR vector2) const
 Returns the angle between two vectors, choosing the smaller of the two possible angles when both the vectors and their negations are considered. More...
 
double SmallerUnorientedAngleToXY (DVec3dCR vector2) const
 Returns the angle between two vectors, considering both the vectors and their negations and choosing the smaller. More...
 
double AngleFromPerpendicular (DVec3dCR vector2) const
 Returns the angle that two vectors deviate from being perpendicular. More...
 
double SignedAngleTo (DVec3dCR vector2, DVec3dCR orientationVector) const
 Computes the signed angle from one vector to another, in the plane of the two vectors. More...
 
double PlanarAngleTo (DVec3dCR vector2, DVec3dCR planeNormal) const
 Computes the signed angle between the projection of two vectors onto a plane with given normal. More...
 
bool AngleAndAxisOfRotationFromVectorToVector (DVec3dCR target, DVec3dR axis, double &radians) const
 Compute an axis and angle to rotate from the instance vector to a target. More...
 
bool IsVectorInSmallerSector (DVec3dCR vector0, DVec3dCR vector1) const
 Test a vector is "between" vector0 and vector1. More...
 
bool IsVectorInCCWSector (DVec3dCR vector0, DVec3dCR vector1, DVec3dCR upVector) const
 Test if the test vector vector is "between" vector0 and vector1, with CCW direction resolved by an up vector. More...
 
bool IsVectorInCCWXYSector (DVec3dCR vector0, DVec3dCR vector1) const
 Test if the instance vector vector is "between" vector0 and vector1, with CCW direction using only xy parts. More...
 
bool IsParallelTo (DVec3dCR vector2) const
 Tests if two vectors are parallel (opposites are considered parallel!) More...
 
bool IsPositiveParallelTo (DVec3dCR vector2) const
 Tests if two vectors are parallel and have positive dot product (opposites are NOT considered parallel) More...
 
bool IsPerpendicularTo (DVec3dCR vector2) const
 Tests if two vectors are perpendicular. More...
 
bool IsEqual (DVec3dCR vector2) const
 Test for exact equality between all components of two vectors. More...
 
bool IsEqual (DVec3dCR vector2, double tolerance) const
 Test if the x, y, and z components of two vectors are equal within tolerance. More...
 
bool AlmostEqual (DVec3d const &dataB) const
 test if two points are equal. More...
 
bool IsZero ()
 checks if the vector has all zeros More...
 
- Public Member Functions inherited from DPoint3d
void Swap (DPoint3dR other)
 Swap contents of instance, other. More...
 
double CrossProductToPointsXY (DPoint3dCR target1, DPoint3dCR target2) const
 Returns the (scalar) cross product of the xy parts of two vectors. More...
 
double DotProductToPoints (DPoint3dCR target1, DPoint3dCR target2) const
 Returns the (scalar) dot product of two vectors. More...
 
double DotProductToPointsXY (DPoint3dCR target1, DPoint3dCR target2) const
 Returns the (scalar) dot product of xy parts of two vectors. More...
 
double DotDifference (DPoint3dCR origin, DVec3dCR vector) const
 Returns the (scalar) dot product of a two vectors. More...
 
double TripleProductToPoints (DPoint3dCR target1, DPoint3dCR target2, DPoint3dCR target3) const
 Computes the triple product of vectors from a base point three target points. More...
 
void Zero ()
 Sets all components of a point or vector to zero. More...
 
void One ()
 Returns a point or vector with all components 1.0. More...
 
void InitFromArray (const double *pXyz)
 Copies doubles from a 3 component array to the x,y, and z components of a DPoint3d. More...
 
void Init (DPoint2dCR source)
 Copy from a 2d point setting z to zero. More...
 
void Init (double ax, double ay, double az)
 Sets the x,y, and z components of a point. More...
 
void Init (double ax, double ay)
 Sets the x, and y components of a point. More...
 
void XyzOf (DPoint4dCR hPoint)
 Sets the x,y, and z components of a DPoint3d structure from the corresponding parts of a DPoint4d. More...
 
void SetComponent (double a, int index)
 Set one of three components (x,y,z) of the point. More...
 
double GetComponent (int index) const
 Gets a single component of a point. More...
 
void GetComponents (double &xCoord, double &yCoord, double &zCoord) const
 Copies x,y,z components from a point to individual variables. More...
 
void Interpolate (DPoint3dCR point0, double fractionParameter, DPoint3dCR point1)
 Computes a point whose position is given by a fractional argument and two endpoints. More...
 
bool IsPointInSmallerSector (DPoint3dCR origin, DPoint3dCR target1, DPoint3dCR target2) const
 Form vectors from the origin to the test point and the two boundary vectors. More...
 
bool IsPointInCCWector (DPoint3dCR origin, DPoint3dCR target0, DPoint3dCR target1, DVec3dCR upVector) const
 Test if a point is within the counter-clockwise sector defined by an origin and two boundary points, with an up vector to determine which direction is counter clockwise. More...
 
double Distance (DPoint3dCR point2) const
 Computes the (cartesian) distance between two points. More...
 
double DistanceSquared (DPoint3dCR point2) const
 Computes the squared distance between two points. More...
 
double DistanceSquaredXY (DPoint3dCR point2) const
 Computes the squared distance between two points, using only the xy parts. More...
 
double DistanceXY (DPoint3dCR point2) const
 Computes the distance between two points, using only x and y components. More...
 
bool DistanceXY (DPoint3dCR otherPoint, DMatrix4dCP matrix, double &distance) const
 Computes the distance between two points, using only x and y components, optionally applying a transform into view space. More...
 
double MaxAbs () const
 Finds the largest absolute value among the components of a point or vector. More...
 
double MinAbs () const
 Finds the smallest absolute value among the components of a point or vector. More...
 
int MaxAbsIndex () const
 return in the index of the MaxAbs () value. More...
 
int MinAbsIndex () const
 return in the index of the MinAbs () value More...
 
DRange1d ComponentRange () const
 
bool IsEqual (DPoint3dCR point2) const
 Test for exact equality between all components of two points or vectors. More...
 
bool IsEqual (DPoint3dCR point2, double tolerance) const
 Test if the x, y, and z components of two points or vectors are equal within tolerance. More...
 
void NpcCoordinatesOf (DPoint3dCR point, DRange3dCR cube)
 Computes the coordinates of point under the translation and scaling that puts 000 at cube>low and 111 at cube>high. More...
 
bool IsDisconnect () const
 
void InitDisconnect ()
 Initialize a point with all coordinates as the disconnect value. More...
 
void Init (DVec3dCR vector)
 Initialize a point by copying x,y,z from a vector. More...
 
void Subtract (DPoint3dCR base, DVec3dCR vector)
 Subtract a vector from a point. More...
 
void Add (DVec3dCR vector)
 Adds a vector to a pointer or vector, returns the result in place. More...
 
void SumOf (DPoint3dCR origin, DVec3dCR vector, double scale)
 Adds an origin and a scaled vector. More...
 
void SumOf (DPoint3dCR origin, DVec3dCR point1, double scale1, DVec3dCR point2, double scale2)
 Adds an origin and two scaled vectors. More...
 
void SumOf (DPoint3dCR origin, DVec3dCR point1, double scale1, DVec3dCR point2, double scale2, DVec3dCR point3, double scale3)
 Adds an origin and three scaled vectors. More...
 
void CrossProduct (DPoint3dCR point1, DPoint3dCR point2)
 Returns the cross (vector) cross product of two vectors. More...
 
void CrossProductToPoints (DPoint3dCR origin, DPoint3dCR target1, DPoint3dCR target2)
 Returns the (vector) cross product of two vectors. More...
 
double CrossProductXY (DPoint3dCR point2) const
 Return the (scalar) cross product of the xy parts of two vectors. More...
 
double NormalizedCrossProduct (DPoint3dCR point1, DPoint3dCR point2)
 Compute the normalized cross product of two vectors and return the length of the unnormalized cross product. More...
 
double SizedCrossProduct (DPoint3dCR point1, DPoint3dCR point2, double productLength)
 Computes the cross product of the two parameter vectors and scales it to a given length. More...
 
double GeometricMeanCrossProduct (DPoint3dCR point1, DPoint3dCR point2)
 Computes the cross product of two vectors and scales it to the geometric mean of the lengths of the two vectors. More...
 
double DotProduct (DPoint3dCR point2) const
 Returns the (scalar) dot product of two vectors. More...
 
double DotProductXY (DPoint3dCR point2) const
 Returns the (scalar) dot product of xy parts of two vectors. More...
 
double DotProduct (double ax, double ay, double az) const
 Computes the dot product of one vector given as a point structure and another given as xyz components. More...
 
double NormalizedDifference (DPoint3dCR target, DPoint3dCR origin)
 Computes a unit vector in the direction of the difference of the points or vectors (Second parameter vector is subtracted from the first parameter vector, exactly as in the subtract function.) More...
 
double AngleTo (DPoint3dCR point2) const
 Returns the angle between two vectors. More...
 
double AngleXY () const
 Computes the (signed) angle from xy axis to the vector, using only xy parts. More...
 
double SmallerUnorientedAngleTo (DPoint3dCR point2) const
 Returns the angle between two vectors, choosing the smaller of the two possible angles when both the vectors and their negations are considered. More...
 
bool IsVectorInSmallerSector (DPoint3dCR point0, DPoint3dCR point1) const
 Test a vector is "between" point0 and point1. More...
 
bool IsVectorInCCWSector (DPoint3dCR point0, DPoint3dCR point1, DPoint3dCR upVector) const
 Test if the test vector vector is "between" point0 and point1, with CCW direction resolved by an up vector. More...
 
double AngleToXY (DPoint3dCR point2) const
 Returns the angle from Vector1 to Vector2 using only xy parts. More...
 
double SmallerUnorientedAngleToXY (DPoint3dCR point2) const
 Returns the angle between two vectors, considering both the vectors and their negations and choosing the smaller. More...
 
void RotateXY (DPoint3dCR vector, double theta)
 Rotate vector around the z axis, return as calling instance. More...
 
void RotateXY (double theta)
 Rotate the calling instance around the z axis. More...
 
double SignedAngleTo (DPoint3dCR point2, DPoint3dCR orientationVector) const
 Computes the signed from one vector to another, in the plane of the two vectors. More...
 
double PlanarAngleTo (DPoint3dCR point2, DPoint3dCR planeNormal) const
 Computes the signed angle between the projection of two vectors onto a plane with given normal. More...
 
void WeightedDifferenceOf (DPoint4dCR point1, DPoint4dCR point2)
 Scale each point by the other's weight and subtract, i.e. More...
 
void WeightedDifferenceCrossProduct (DPoint4dCR basePoint, DPoint4dCR target1, DPoint4dCR target2)
 Form the cross product of the weighted differences from point0 to point1 and point2. More...
 
double MagnitudeSquared () const
 Computes the squared magnitude of a vector. More...
 
double MagnitudeXY () const
 Computes the magnitude of the xy part of a vector. More...
 
double MagnitudeSquaredXY () const
 Computes the squared magnitude of the xy part of a vector. More...
 
bool UnitPerpendicularXY (DPoint3dCR vector)
 Compute a unit vector perpendicular to the xy parts of given vector. More...
 
double Magnitude () const
 Computes the magnitude of a vector. More...
 
void Scale (DPoint3dCR vector, double scale)
 Multiplies a vector by a scale factor. More...
 
void Scale (double scale)
 Multiplies a vector (in place) by a scale factor. More...
 
void Negate (DPoint3dCR vector)
 Computes a negated (opposite) vector. More...
 
void Negate ()
 Negate a vector in place. More...
 
double Normalize (DPoint3dCR vector)
 Normalizes (scales) a vector to length 1. More...
 
double ScaleToLength (DPoint3dCR vector, double length)
 Scales a vector to specified length. More...
 
double ScaleToLength (double length)
 Scales a vector to a specified length, and returns the prior length. More...
 
double Normalize ()
 Replaces a vector by a unit vector in the same direction, and returns the original length. More...
 
bool IsParallelTo (DPoint3dCR point2) const
 Tests if two vectors are parallel. More...
 
bool IsPerpendicularTo (DPoint3dCR point2) const
 Tests if two vectors are perpendicular. More...
 
bool SafeDivide (DPoint3dCR vector, double denominator)
 Try to divide each component of a vector by a scalar. More...
 
double TripleProduct (DPoint3dCR point2, DPoint3dCR point3) const
 Computes the triple product of three vectors. More...
 
void Subtract (DPoint3dCR point2)
 Subtract two points or vectors, and return the result in place of the first. More...
 
void DifferenceOf (DPoint3dCR point1, DPoint3dCR point2)
 Subtract coordinates of two vectors or points. More...
 
void SumOf (DPoint3dCR origin, DPoint3dCR vector, double scale)
 Adds an origin and a scaled vector. More...
 
void SumOf (DPoint3dCR origin, DPoint3dCR point1, double scale1, DPoint3dCR point2, double scale2)
 Adds an origin and two scaled vectors. More...
 
void SumOf (DPoint3dCR origin, DPoint3dCR point1, double scale1, DPoint3dCR point2, double scale2, DPoint3dCR point3, double scale3)
 Adds an origin and three scaled vectors. More...
 
void SumOf (DPoint3dCR point1, double a1, DPoint3dCR point2, double a2)
 Componentwise linear combination. More...
 
void SumOf (DPoint3dCR point1, double a1, DPoint3dCR point2, double a2, DPoint3dCR point3, double a3)
 Componentwise linear combination. More...
 
void Add (DPoint3dCR vector)
 Adds a vector to a pointer or vector, returns the result in place. More...
 
void SumOf (DPoint3dCR point1, DPoint3dCR point2)
 Compute the sum of two points or vectors. More...
 
bool AlmostEqual (DPoint3d const &dataB) const
 test if two points are equal. More...
 
bool AlmostEqualXY (DPoint3d const &dataB) const
 test if two points are equal. More...
 
bool AlmostEqual (DPoint3d const &dataB, double abstol) const
 test if two points are equal. More...
 
bool AlmostEqualXY (DPoint3d const &dataB, double abstol) const
 test if two points are equal. More...
 

Static Public Member Functions

static DVec3d FromArray (const double *pXyz)
 Returns a DVec3d with 3 component array of double. More...
 
static DVec3d UnitX ()
 unit X vector More...
 
static DVec3d UnitY ()
 unit Y vector More...
 
static DVec3d UnitZ ()
 unit Z vector More...
 
static DVec3d From (double ax, double ay, double az=0.0)
 Returns a DVec3d with given x,y, and z components of a vector. More...
 
static DVec3d From (DPoint3dCR point)
 Returns a DVec3d from a point (treating the point as a vector from its origin). More...
 
static DVec3d From (DVec2dCR vector)
 Returns a DVec3d from a 2d vector (with 0 z) More...
 
static DVec3d FromStartEnd (DPoint3dCR start, DPoint3dCR end)
 Returns the unnormalized (full length) DVec3d between start and end. More...
 
static DVec3d FromStartEnd (TransformCR start, DPoint3dCR target)
 Returns the unnormalized (full length) DVec3d from the frame origin to the target point. More...
 
static DVec3d FromStartEndNormalize (DPoint3dCR start, DPoint3dCR end)
 Returns a vector from start towards end, normalized if nonzero. More...
 
static DVec3d FromCCWPerpendicularXY (DVec3d source)
 return a vector same length as source but rotate 90 degrees CCW More...
 
static DVec3d FromRotate90Towards (DVec3dCR source, DVec3dCR target)
 return a vector same length as source but rotate 90 degrees towards target More...
 
static DVec3d FromRotate90Around (DVec3dCR source, DVec3dCR axis)
 return a vector same length as source but rotate 90 degrees around axis More...
 
static DVec3d FromXYAngleAndMagnitude (double theta, double magnitude)
 Returns a DVec3d from given angle and distance in xy plane. More...
 
static DVec3d FromTranslation (TransformCR source)
 return the translation xyz as a DVec3d (which you can pass as a DPoint3d where needed.) More...
 
static DVec3d FromMatrixColumn (TransformCR transform, int i)
 return a (cyclically indexed) column of the matrix part of a transform. More...
 
static DVec3d FromMatrixRow (TransformCR transform, int i)
 return a (cyclically indexed) row of the matrix part of a transform. More...
 
static DVec3d FromColumn (RotMatrixCR matrix, int i)
 return a (cyclically indexed) column of the matrix. More...
 
static DVec3d FromRow (RotMatrixCR matrix, int i)
 return a (cyclically indexed) row of the matrix. More...
 
static DVec3d FromStartEnd (DPoint4dCR start, DPoint4dCR end)
 Returns DVec3d pseudo difference start.w*end - end.w*start. More...
 
static DVec3d FromCrossProduct (DVec3dCR vector0, DVec3dCR vector1)
 return the cross product of vectors More...
 
static DVec3d FromCrossProductToPoints (DPoint3dCR origin, DPoint3dCR target1, DPoint3dCR target2)
 Returns the (vector) cross product of two vectors. More...
 
static DVec3d FromNormalizedCrossProductToPoints (DPoint3dCR origin, DPoint3dCR target1, DPoint3dCR target2)
 Returns the (normalized vector) cross product of two vectors. More...
 
static DVec3d FromNormalizedCrossProduct (DVec3dCR vector0, DVec3dCR vector1)
 return the normalized cross product of vectors More...
 
static DVec3d FromCrossProduct (double x0, double y0, double z0, double x1, double y1, double z1)
 return the cross product of vectors presented as explicit components More...
 
static DVec3d FromMatrixColumnCrossProduct (TransformCR transform, int i, int j)
 return the cross product of vectors found in columns of (the matrix part of) a transform. More...
 
static DVec3d FromColumnCrossProduct (RotMatrixCR matrix, int i, int j)
 return the cross product of vectors found in columns a matrix More...
 
static ValidatedDVec3d FromUnitPerpendicularXY (DVec3dCR vector)
 Compute a unit vector perpendicular to the xy parts of given vector. More...
 
static DVec3d FromInterpolate (DVec3dCR vector0, double fraction, DVec3dCR vector1)
 Returns an interpolated vector. More...
 
static DVec3d FromInterpolateBilinear (DVec3dCR vector00, DVec3dCR vector10, DVec3dCR vector01, DVec3dCR vector11, double u, double v)
 Returns a bilinear interpolation from corners (00)(10)(01)(11) More...
 
static DVec3d FromSumOf (DVec3dCR vector0, DVec3dCR vector1)
 Returns a sum of vectors. More...
 
static DVec3d FromSumOf (DVec3dCR vector0, double scale0, DVec3dCR vector1, double scale1)
 Returns a linear combination of vectors. More...
 
static DVec3d FromSumOf (DVec3dCR vector0, double scale0, DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2)
 Returns a linear combination of vectors. More...
 
static DVec3d FromSumOf (DVec3dCR vector0, DVec3dCR vector1, double scale1)
 Returns a linear combination of vectors. More...
 
static DVec3d FromSumOf (DVec3dCR vector0, DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2)
 Returns a linear combination of vectors. More...
 
static DVec3d FromSumOf (DVec3dCR vector0, DVec3dCR vector1, double scale1, DVec3dCR vector2, double scale2, DVec3dCR vector3, double scale3)
 Returns a linear combination of vectors. More...
 
static DVec3d FromScale (DVec3dCR vector, double scale)
 Returns a scalar multiple of a DVec3d. More...
 
static DVec3d FromWeightedDifferenceOf (DPoint4dCR hPoint1, DPoint3dCR point2)
 Promote point2 to homogeneous and form (point1 *point2.w - point2 * point1.w). More...
 
- Static Public Member Functions inherited from DPoint3d
static DPoint3d From (double x, double y, double z=0.0)
 Return a DPoint3d with given xyz. More...
 
static DPoint3d From (DPoint2dCR xy)
 Return a DPoint3d with given xy, z = 0;. More...
 
static DPoint3d FromZero ()
 Return a DPoint3d with xyz = 0. More...
 
static DPoint3d FromOne ()
 Return a DPoint3d with xyz = 1. More...
 
static DPoint3d FromArray (const double *pXyz)
 Simple initialization from 3 coordinates in array. More...
 
static void AddToArray (DPoint3dP points, int n, DPoint3dCR delta)
 Add translation to all points. More...
 
static void MultiplyArrayByScales (DPoint3dP pDest, DPoint3dCP pSource, double *pScales, int n)
 Multiply each point in an array by its corresponding scale factor. More...
 
static void DivideArrayByScales (DPoint3dP pDest, DPoint3dCP pSource, double *pScales, int n)
 Divide each point in an array by its corresponding scale factor. More...
 
static DPoint3d FromProduct (TransformCR transform, double x, double y, double z)
 return product of transform times point given as components. More...
 
static DPoint3d FromProduct (TransformCR transform, DPoint3dCR point)
 return product of transform times point More...
 
static DPoint3d FromInterpolate (DPoint3dCR pointA, double fraction, DPoint3dCR pointB)
 interpolate between points. More...
 
static DPoint3d FromInterpolateBilinear (DPoint3dCR point00, DPoint3dCR point10, DPoint3dCR point01, DPoint3dCR point11, double u, double v)
 Returns a bilinear interpolation from corners (00)(10)(01)(11) More...
 
static DPoint3d FromSumOf (DPoint3dCR origin, DPoint3dCR vector)
 Add a point and a vector. More...
 
static DPoint3d FromSumOf (DPoint3dCR origin, DPoint3dCR vector, double scaleFactor)
 Add scaled vector from origin. More...
 
static DPoint3d FromSumOf (DPoint3dCR origin, DPoint3dCR point0, double scaleFactor0, DPoint3dCR point1, double scaleFactor1)
 Add scaled vectors from an origin. More...
 
static DPoint3d FromSumOf (DPoint3dCR origin, DPoint3dCR point0, double scaleFactor0, DPoint3dCR point1, double scaleFactor1, DPoint3dCR point2, double scaleFactor2)
 Add scaled vectors from origin. More...
 
static DPoint3d FromScale (DPoint3d point, double scale)
 Returns a scalar multiple of a DPoint3d. More...
 
static DPoint3d FromSumOf (DPoint3dCR point0, double scale0, DPoint3dCR point1, double scale1)
 Returns a linear combination of points. More...
 
static DPoint3d FromSumOf (DPoint3dCR point0, double scale0, DPoint3dCR point1, double scale1, DPoint3dCR point2, double scale2)
 Returns a linear combination of points. More...
 
static DPoint3d FromProduct (DPoint3dCR point, RotMatrixCR matrix, double x, double y, double z)
 Return {point + matrix * (x,y,z)}. More...
 
static DPoint3d FromProduct (DPoint3dCR point, RotMatrixCR matrix, DVec3dCR vector)
 Return {point + matrix * vector}. More...
 
static bool AlmostEqual (bvector< DPoint3d > const &left, bvector< DPoint3d > const &right, double tolerance=0.0)
 apply AlmostEqual test to corresponding points More...
 
static bool AlmostEqualXY (bvector< DPoint3d > const &left, bvector< DPoint3d > const &right, double tolerance=0.0)
 apply AlmostEqualXY test to corresponding points More...
 

Additional Inherited Members

- Public Attributes inherited from DPoint3d
double x
 x coordinate More...
 
double y
 y coordinate More...
 
double z
 z coordinate More...
 

Detailed Description

Vector with x,y,z components.

>DVec3d Usage Summary
Method Invocation

Remarks

W.crossProduct(U,V) W = U cross V
W.crossProductToPoints (A,B,C) W = (B-A) cross (C-A)
W.normalizedCrossProduct (U,V) W = normalize (U cross V)
W.sizedCrossProduct (U,V, a) W = a * normalize (U cross V)
W.geometricMeanCrossProduct (U,V)

W = sqrt (mag(U) * mag(V)) * normalize(U cross V)

a = crossProductXY (U,V) a = U cross V (xy only, scalar result)
a = tripleProduct (U,V,W)va = U cross V dot W
a = tripleProductToPoints (A,B,C,D) a = (B-A) cross (C-A) dot (D-A)
a = dotProduct (U,V) a = U dot V
a = dotProductXY (U,V)

a = U dot V, using only x and y parts

U.getTriad (&Vx ,&Vy, &Vz) return Vz=U, Vx,Vy perpenidcular, same length
U.getNormalizedTriad (&Vx, &Vy, &Vz)

return Vz=normalize(U), Vx,Vy perpenidcular, all unit

U.normalizedDifference (A,B)

U = normalize (A-B)

a = U.angleTo (V) Spatial angle from U to V. Range 0 to PI.
a = U.angleToXY (V)
a = U.smallerUnorientedAngleTo (V)
a = U.smallerUnorientedAngleToXY (V)
a = U.signedAngleTo (V, upVector)

U.isVectorInSmallerSector(V,W) Test if U appears in the smaller sector between V and W, when viewed with V cross W as up vector.
U.isVectorInCCWSector (V,W, upVector)) Test if U appears in the sector from V counterclockwise towards W when viewed with upVector
U.planarAngleTo (V,W) Anlge after projection to plane with nomral W.
U.rotateXY (V, theta) rotate around z axis
U.rotateXY (theta)

Inplace rotation around z

U.unitPerpendicularXY (V)
U.scale (V,a) U = V * a
U.scale (a) U *= a
U.negate () U *= -1
U.negate(V) U = - V
U.normalize (V) U = V / V.magnitude ()
U.normalize () U /= U.magnitude ()
U.scaleToLength (V,a)

U = V * a / V.magnitude ()

U.isParallelTo(V)
U.isPerpendicularTo(V)
if (U.safeDivide) ... (V,a)

Divde by a, but return false if a is too close to zero

U.zero() Sets all components to 0
U.one() Sets all components to 1
U.init (x,y,z)
U.init (A) copy from point
U.setComponent (a, i) Set individual components
a = U.getComponent (i) Get individual component
U.getComponents (U, &a, &b, &c)

Get all components as separate doubles

U.sumOf (V,W) U = V + W
U.add (V) U += V
U.subtract (V) U -= V
U.sumOf (V, W, a) U = V + a W
U.interpolate (V, a, W) U = (1-a)V * a W
W.sumOf (U, V1, a1, V2, a2) W = U + a1 * V1 + a2 * V2 + a3 * V3
W.sumOf (U, V1, a1, V2, a2, V2, a3) W = U + a1 * V1 + a2 * V2 + a3 * V3
W.differenceOf (U,V) W = U - V
W.differenceOf (A,B)

W = A - B

a = U.distance (V) W = (V-U).magnitude ()
a = U.distanceSquared(V)
a = U.distanceXY (V)
a = U.distanceSquaredXY (V)

a = U.magnitudeSquared ()
a = U.magnitudeSquaredXY ()
a = U.magnitude ()
a = U.magnitudeXY ()

a = U.maxAbs()

U.isEqual(V) Bitwise equality
U.isEqual (V, tol) componentwise absolute difference

U.multiply (M,V) U = M * V<
mutliplyArray (U[], M, V[], count)
U.multiply (M, x, y, z) U = M * <x,y,z>
U.multiplyTranspose (M, V) U = M^ * V
U.multiplyTranspose (M, x, y, z) U = M' * <x,y,z>
Dvec3d::multiplyTransposeArray (U[], M, V[], count)

Member Function Documentation

void Add ( DVec3dCR  vector)

Adds a vector to a pointer or vector, returns the result in place.

Parameters
[in]vectorThe vector to add.
bool AlmostEqual ( DVec3d const &  dataB) const

test if two points are equal.

Uses library "small angle" as both absolute and relative tolerance. points are equal if squared distance between is less than (squared abstol) plus (squared relTol) * sum of cmponent squares

Parameters
[in]dataBsecond DVec3d
Returns
true if within tolerance.
bool AngleAndAxisOfRotationFromVectorToVector ( DVec3dCR  target,
DVec3dR  axis,
double &  radians 
) const

Compute an axis and angle to rotate from the instance vector to a target.

Parameters
[out]targetdirection that the instance is to rotate towards.
[out]axisreturned axis of rotation
[out]radiansreturned rotation angle
Returns
true if both vectors are nonzero.
double AngleFromPerpendicular ( DVec3dCR  vector2) const

Returns the angle that two vectors deviate from being perpendicular.

double AngleTo ( DVec3dCR  vector2) const

Returns the angle between two vectors.

This angle is between 0 and pi. Rotating the first vector by this angle around the cross product between the vectors aligns it with the second vector.

Parameters
[in]vector2The second vector
Returns
The angle between the vectors.
double AngleToXY ( DVec3dCR  vector2) const

Returns the angle from Vector1 to Vector2 using only xy parts.

This angle is between -pi and +pi.

Parameters
[in]vector2The second vector
Returns
The angle between vectors.
void CrossProduct ( DVec3dCR  vector1,
DVec3dCR  vector2 
)

Returns the (vector) cross product of two vectors.

Parameters
[in]vector1The first vector
[in]vector2The second vector
void CrossProduct ( DVec3dCR  vector1,
DPoint3dCR  point2 
)

Returns the (vector) cross product of two vectors.

Parameters
[in]vector1The first vector
[in]point2The second vector, given as a point. The point's xyz are understood to be a vector from the origin.
void CrossProduct ( DPoint3dCR  point1,
DVec3dCR  vector2 
)

Returns the (vector) cross product of two vectors.

Parameters
[in]point1The first vector, givenn as a point. The point's xyz are understood to be a vector from the origin.
[in]vector2The second vector.
double CrossProductMagnitude ( DVec3dCR  other) const

Compute the cross product with other and return is magnitude (but the cross product is not returned)

Parameters
[in]othersecond vector of cross product
void CrossProductToPoints ( DPoint3dCR  origin,
DPoint3dCR  target1,
DPoint3dCR  target2 
)

Sets the instance to the (vector) cross product of two vectors.

The vectors are computed from the Origin to Target1 and Target2.

Parameters
[in]originThe base point for computing vectors.
[in]target1The target point for the first vector.
[in]target2The target point for the second vector.
double CrossProductXY ( DVec3dCR  vector2) const

Return the (scalar) cross product of the xy parts of two vectors.

Parameters
[in]vector2The second vector
Returns
The 2d cross product.
void DifferenceOf ( DVec3dCR  vector1,
DVec3dCR  vector2 
)

Subtract coordinates of two vectors.

(Compute Vector1 - Vector2)

Parameters
[in]vector1The first vector
[in]vector2The second (subtracted) vector
void DifferenceOf ( DPoint3dCR  target,
DPoint3dCR  base 
)

Subtract coordinates of two points.

(Compute Point1 - Point2)

Parameters
[in]targetThe target point
[in]baseThe base point
double Distance ( DVec3dCR  vector2) const

Computes the (cartesian) distance between two vectors.

Parameters
[in]vector2The second vector
Returns
The distance between vector.
double DistanceSquared ( DVec3dCR  vector2) const

Computes the squared distance between two vectors.

Parameters
[in]vector2The second vector.
Returns
The squared distance between the vectors.
double DistanceSquaredXY ( DVec3dCR  vector2) const

Computes the squared distance between two vectors, using only the xy parts.

Parameters
[in]vector2The second vector
Returns
The squared distance between the XY projections of the two vectors. (i.e. any z difference is ignored)
double DistanceXY ( DVec3dCR  vector2) const

Computes the distance between two vectors, using only x and y components.

Parameters
[in]vector2The second vector
Returns
The distance between the XY projections of the two vectors. (i.e. any z difference is ignored)
double DotProduct ( DVec3dCR  vector2) const

Returns the (scalar) dot product of two vectors.

Parameters
[in]vector2The second vector
Returns
The dot product of the two vectors
double DotProduct ( double  ax,
double  ay,
double  az 
) const

Computes the dot product of one vector given as a vector structure and another given as xyz components.

Parameters
[in]axThe x component of second vector.
[in]ayThe y component of second vector.
[in]azThe z component of second vector.
Returns
The dot product of the vector with a vector with the given components
double DotProduct ( DPoint3dCR  point2) const

Returns the (scalar) dot product of two vectors.

Parameters
[in]point2The second vector, given as point. The point's xyz are understood to be a vector from the origin.
Returns
dot product of the two vectors.
double DotProductColumn ( RotMatrixCR  matrix,
int  index 
) const

Returns the (scalar) dot product of this vector and a column of a matrix.

Parameters
[in]matrix
[in]indexcolumn index.
Returns
The dot product of the two vectors
double DotProductMatrixColumn ( TransformCR  matrix,
int  index 
) const

Returns the (scalar) dot product of this vector and a column of the matrix part of the transform.

Parameters
[in]matrix
[in]indexcolumn index.
Returns
The dot product of the two vectors
double DotProductMatrixRow ( TransformCR  matrix,
int  index 
) const

Returns the (scalar) dot product of this vector and a row of the matrix part of the transform.

Parameters
[in]matrix
[in]indexrow index.
Returns
The dot product of the two vectors
double DotProductRow ( RotMatrixCR  matrix,
int  index 
) const

Returns the (scalar) dot product of this vector and a row of a matrix.

Parameters
[in]matrix
[in]indexrow index.
Returns
The dot product of the two vectors
double DotProductXY ( DVec3dCR  vector2) const

Returns the (scalar) dot product of xy parts of two vectors.

Parameters
[in]vector2The second vector
Returns
The dot product of the xy parts of the two vectors
static DVec3d From ( double  ax,
double  ay,
double  az = 0.0 
)
static

Returns a DVec3d with given x,y, and z components of a vector.

Parameters
[in]axThe x component.
[in]ayThe y component.
[in]azThe z component.

Referenced by DVec3d::UnitX(), DVec3d::UnitY(), and DVec3d::UnitZ().

static DVec3d From ( DPoint3dCR  point)
static

Returns a DVec3d from a point (treating the point as a vector from its origin).

Parameters
[in]pointthe point.
static DVec3d From ( DVec2dCR  vector)
static

Returns a DVec3d from a 2d vector (with 0 z)

Parameters
[in]vectorthe 2d vector
static DVec3d FromArray ( const double *  pXyz)
static

Returns a DVec3d with 3 component array of double.

Parameters
[in]pXyzx, y, z components
static DVec3d FromCCWPerpendicularXY ( DVec3d  source)
static

return a vector same length as source but rotate 90 degrees CCW

static DVec3d FromColumn ( RotMatrixCR  matrix,
int  i 
)
static

return a (cyclically indexed) column of the matrix.

Parameters
[in]matrixsource
[in]icolumn index
static DVec3d FromColumnCrossProduct ( RotMatrixCR  matrix,
int  i,
int  j 
)
static

return the cross product of vectors found in columns a matrix

Parameters
[in]matrixsource transform
[in]ifirst column index
[in]jsecond column index
static DVec3d FromCrossProduct ( DVec3dCR  vector0,
DVec3dCR  vector1 
)
static

return the cross product of vectors

Parameters
[in]vector0first vector
[in]vector1second vector
static DVec3d FromCrossProduct ( double  x0,
double  y0,
double  z0,
double  x1,
double  y1,
double  z1 
)
static

return the cross product of vectors presented as explicit components

Parameters
[in]x0vector0 x component
[in]y0vector0 y component
[in]z0vector0 z component
[in]x1vector1 x component
[in]y1vector1 y component
[in]z1vector1 z component
static DVec3d FromCrossProductToPoints ( DPoint3dCR  origin,
DPoint3dCR  target1,
DPoint3dCR  target2 
)
static

Returns the (vector) cross product of two vectors.

The vectors are computed from the Origin to Target1 and Target2.

Parameters
[in]originThe base point for computing vectors.
[in]target1The target point for the first vector.
[in]target2The target point for the second vector.
static DVec3d FromInterpolate ( DVec3dCR  vector0,
double  fraction,
DVec3dCR  vector1 
)
static

Returns an interpolated vector.

Parameters
[in]vector0vector at fraction 0
[in]fractionfraction from interpolation.
[in]vector1vector at fraction 1
static DVec3d FromInterpolateBilinear ( DVec3dCR  vector00,
DVec3dCR  vector10,
DVec3dCR  vector01,
DVec3dCR  vector11,
double  u,
double  v 
)
static

Returns a bilinear interpolation from corners (00)(10)(01)(11)

Parameters
[in]vector00vector at (0,0)
[in]vector10vector at (1,0)
[in]vector01vector at (0,1)
[in]vector11vector at (1,1)
[in]uinterpolation fraction for edges (vector00,vector10) and (vector01,vector11)
[in]vinterpolation fraction for edges (vector00,vector10) and (vector10,vector11)
static DVec3d FromMatrixColumn ( TransformCR  transform,
int  i 
)
static

return a (cyclically indexed) column of the matrix part of a transform.

Parameters
[in]transformsource transform
[in]icolumn index
static DVec3d FromMatrixColumnCrossProduct ( TransformCR  transform,
int  i,
int  j 
)
static

return the cross product of vectors found in columns of (the matrix part of) a transform.

Parameters
[in]transformsource transform
[in]ifirst column index
[in]jsecond column index
static DVec3d FromMatrixRow ( TransformCR  transform,
int  i 
)
static

return a (cyclically indexed) row of the matrix part of a transform.

Parameters
[in]transformsource transform
[in]irow index
static DVec3d FromNormalizedCrossProduct ( DVec3dCR  vector0,
DVec3dCR  vector1 
)
static

return the normalized cross product of vectors

Parameters
[in]vector0first vector
[in]vector1second vector
static DVec3d FromNormalizedCrossProductToPoints ( DPoint3dCR  origin,
DPoint3dCR  target1,
DPoint3dCR  target2 
)
static

Returns the (normalized vector) cross product of two vectors.

The vectors are computed from the Origin to Target1 and Target2. If the cross product is zero, a zero vector is returned.

Parameters
[in]originThe base point for computing vectors.
[in]target1The target point for the first vector.
[in]target2The target point for the second vector.
static DVec3d FromRotate90Around ( DVec3dCR  source,
DVec3dCR  axis 
)
static

return a vector same length as source but rotate 90 degrees around axis

static DVec3d FromRotate90Towards ( DVec3dCR  source,
DVec3dCR  target 
)
static

return a vector same length as source but rotate 90 degrees towards target

static DVec3d FromRow ( RotMatrixCR  matrix,
int  i 
)
static

return a (cyclically indexed) row of the matrix.

Parameters
[in]matrixsource
[in]irow index
static DVec3d FromScale ( DVec3dCR  vector,
double  scale 
)
static

Returns a scalar multiple of a DVec3d.

Parameters
[in]vectorinput vector
[in]scalescale factor
static DVec3d FromStartEnd ( DPoint3dCR  start,
DPoint3dCR  end 
)
static

Returns the unnormalized (full length) DVec3d between start and end.

Parameters
[in]startstart point
[in]endend point
static DVec3d FromStartEnd ( TransformCR  start,
DPoint3dCR  target 
)
static

Returns the unnormalized (full length) DVec3d from the frame origin to the target point.

Parameters
[in]startstart point
[in]targetend point
static DVec3d FromStartEnd ( DPoint4dCR  start,
DPoint4dCR  end 
)
static

Returns DVec3d pseudo difference start.w*end - end.w*start.

Parameters
[in]startstart point
[in]endend point
static DVec3d FromStartEndNormalize ( DPoint3dCR  start,
DPoint3dCR  end 
)
static

Returns a vector from start towards end, normalized if nonzero.

Parameters
[in]startstart point
[in]endend point
static DVec3d FromSumOf ( DVec3dCR  vector0,
DVec3dCR  vector1 
)
static

Returns a sum of vectors.

Parameters
[in]vector0first vector
[in]vector1second vector
static DVec3d FromSumOf ( DVec3dCR  vector0,
double  scale0,
DVec3dCR  vector1,
double  scale1 
)
static

Returns a linear combination of vectors.

Parameters
[in]vector0first vector
[in]scale0first scale
[in]vector1second vector
[in]scale1second scale
static DVec3d FromSumOf ( DVec3dCR  vector0,
double  scale0,
DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2 
)
static

Returns a linear combination of vectors.

Parameters
[in]vector0first vector
[in]scale0first scale
[in]vector1second vector
[in]scale1second scale
[in]vector2third vector
[in]scale2third scale
static DVec3d FromSumOf ( DVec3dCR  vector0,
DVec3dCR  vector1,
double  scale1 
)
static

Returns a linear combination of vectors.

Parameters
[in]vector0first vector
[in]vector1second vector
[in]scale1second scale
static DVec3d FromSumOf ( DVec3dCR  vector0,
DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2 
)
static

Returns a linear combination of vectors.

Parameters
[in]vector0first vector
[in]vector1second vector
[in]scale1second scale
[in]vector2third vector
[in]scale2third scale
static DVec3d FromSumOf ( DVec3dCR  vector0,
DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2,
DVec3dCR  vector3,
double  scale3 
)
static

Returns a linear combination of vectors.

Parameters
[in]vector0first vector
[in]vector1second vector
[in]scale1scale for vector1
[in]vector2third vector
[in]scale2scale fro vector2
[in]vector3fourth vector
[in]scale3scale for vector3
static DVec3d FromTranslation ( TransformCR  source)
static

return the translation xyz as a DVec3d (which you can pass as a DPoint3d where needed.)

Parameters
[in]sourcesource transform
static ValidatedDVec3d FromUnitPerpendicularXY ( DVec3dCR  vector)
static

Compute a unit vector perpendicular to the xy parts of given vector.

Parameters
[in]vectorThe source vector
Returns
perpendicular vector, marked invalid if unable to divide.
static DVec3d FromWeightedDifferenceOf ( DPoint4dCR  hPoint1,
DPoint3dCR  point2 
)
static

Promote point2 to homogeneous and form (point1 *point2.w - point2 * point1.w).

The weight term vanishes. Copy the xyz parts back as a vector.

Parameters
[in]hPoint1The first homogeneous point
[in]point2The second point.
static DVec3d FromXYAngleAndMagnitude ( double  theta,
double  magnitude 
)
static

Returns a DVec3d from given angle and distance in xy plane.

Z part is set to zero.

Parameters
[in]thetaAngle from X axis to the vector, in the xy plane.
[in]magnitudeVector magnitude
double GeometricMeanCrossProduct ( DVec3dCR  vector1,
DVec3dCR  vector2 
)

Computes the cross product of two vectors and scales it to the geometric mean of the lengths of the two vectors.

This is useful because it has the direction of the cross product (i.e. normal to the plane of the two vectors) and a size in between the two vectors.

Parameters
[in]vector1The first vector
[in]vector2The second vector
Returns
The The length of unscaled cross product.
double GetComponent ( int  index) const

Gets a single component of a vector.

If the index is out of range 0,1,2, it is interpreted cyclically.

Parameters
[in]indexIndicates which component is accessed. The values are 0=x, 1=y, 2=z. Other values are treated cyclically.
Returns
The specified component of the vector.
void GetComponents ( double &  xCoord,
double &  yCoord,
double &  zCoord 
) const

Copies x,y,z components from a vector to individual variables.

Parameters
[out]xCoordx component
[out]yCoordy component
[out]zCoordz component
bool GetNormalizedTriad ( DVec3dR  xAxis,
DVec3dR  yAxis,
DVec3dR  zAxis 
) const

Sets three vectors so that they are mutually perpendicular unit vectors with the third (Z) vector in the direction of the given axis vector.

If the given axis vector contains only zeros, a (0,0,1) vector is used instead.

Parameters
[out]xAxisunit x direction vector
[out]yAxisunit y direction vector
[out]zAxisunit z direction vector
Returns
true unless given vector has zero length.
bool GetPerpendicularParts ( DVec3dCR  hypotenuse,
double &  fraction,
DVec3dR  parallelPart,
DVec3dR  perpendicularPart 
) const

Decompose hypotenuse into a vector parallel to the instance and a vector perpendicular to the instance.

Parameters
[in]hypotenusevector to decompose
[out]fractionposition where hypotenuse projects onto the instance.
[out]parallelPartvector parallel to the instance
[out]perpendicularPartvector perpendicular to the instance
bool GetTriad ( DVec3dR  xAxis,
DVec3dR  yAxis,
DVec3dR  zAxis 
) const

Sets three vectors so that they are mutually perpendicular, the third (Z) vector is identical to the given axis vector, and all have the same length.

If the given axis vector contains only zeros, a (0,0,1) vector is used instead.

Parameters
[out]xAxisx direction of the coordinate system
[out]yAxisy direction of the coordinate system
[out]zAxisz direction of the coordinate system
Returns
true unless given vector is z zero vector.
void Init ( double  ax,
double  ay,
double  az 
)

Sets the x,y, and z components of a vector.

Parameters
[in]axThe x component.
[in]ayThe y component.
[in]azThe z component.
void Init ( double  ax,
double  ay 
)

Sets the x, and y components of a vector.

Sets z to zero.

Parameters
[in]axThe x component.
[in]axThe x component.
[in]ayThe y component
void Init ( DPoint3dCR  point)

Initialize a vector from a point (treating the point as a vector from its origin).

Parameters
[in]pointthe point.
void InitFromArray ( double const *  pXyz)

Copies doubles from a 3 component array to the x,y, and z components of a DVec3d.

Parameters
[in]pXyzx, y, z components
void InitFromColumn ( RotMatrixCR  matrix,
int  col 
)

Extracts a column of a matrix.

Parameters
[in]matrixThe matrix.
[in]colcolumn index. Columns are numbered 0,1,2. Others indices are reduced cyclically.
void InitFromRow ( RotMatrixCR  matrix,
int  row 
)

Extracts a row of a matrix.

Parameters
[in]matrixThe matrix.
[in]rowrow index. Rows are numbered 0,1,2. Others indices are reduced cyclically.
void InitFromXYAngleAndMagnitude ( double  theta,
double  magnitude 
)

Sets a vector from given angle and distance in xy plane.

Z part is set to zero.

Parameters
[in]thetaAngle from X axis to the vector, in the xy plane.
[in]magnitudeVector magnitude
void Interpolate ( DVec3dCR  vector0,
double  fractionParameter,
DVec3dCR  vector1 
)

Computes a vector whose position is given by a fractional argument and two vectors.

Parameters
[in]vector0The vector corresponding to fractionParameter of 0.
[in]fractionParameterThe fractional parametric coordinate. 0.0 is the start of the segment, 1.0 is the end, 0.5 is middle
[in]vector1The vector corresponding to fractionParameter of 1.
bool IsEqual ( DVec3dCR  vector2) const

Test for exact equality between all components of two vectors.

Parameters
[in]vector2The second vector
Returns
true if the vectors are identical.
bool IsEqual ( DVec3dCR  vector2,
double  tolerance 
) const

Test if the x, y, and z components of two vectors are equal within tolerance.

Tests are done independently using the absolute value of each component differences (i.e. not the magnitude or sum of squared differences)

Parameters
[in]vector2The second vector.
[in]toleranceThe tolerance.
Returns
true if all components are within given tolerance of each other.
bool IsParallelTo ( DVec3dCR  vector2) const

Tests if two vectors are parallel (opposites are considered parallel!)

Parameters
[in]vector2The second vector
Returns
true if the vectors are parallel within tolerance
bool IsPerpendicularTo ( DVec3dCR  vector2) const

Tests if two vectors are perpendicular.

Parameters
[in]vector2The second vector
Returns
true if vectors are perpendicular within tolerance
bool IsPositiveParallelTo ( DVec3dCR  vector2) const

Tests if two vectors are parallel and have positive dot product (opposites are NOT considered parallel)

Parameters
[in]vector2The second vector
Returns
true if the vectors are parallel within tolerance
bool IsVectorInCCWSector ( DVec3dCR  vector0,
DVec3dCR  vector1,
DVec3dCR  upVector 
) const

Test if the test vector vector is "between" vector0 and vector1, with CCW direction resolved by an up vector.

The cross product of vector0 and vector1 is considered the positive plane normal if its dot product with the up vector is positive.

Parameters
[in]vector0The boundary vector.
[in]vector1The boundary vector.
[in]upVectorThe out of plane vector.
Returns
true if test vector is within the angle.
bool IsVectorInCCWXYSector ( DVec3dCR  vector0,
DVec3dCR  vector1 
) const

Test if the instance vector vector is "between" vector0 and vector1, with CCW direction using only xy parts.

Parameters
[in]vector0The boundary vector.
[in]vector1The boundary vector.
Returns
true if test vector is within the angle.
bool IsVectorInSmallerSector ( DVec3dCR  vector0,
DVec3dCR  vector1 
) const

Test a vector is "between" vector0 and vector1.

If the vectors are coplanar and vector0 is neither parallel nor antiparallel to vector1, betweenness has the expected meaning: there are two angles between vector0 and vector1; one is less than 180; the test vector is tested to see if it is in the smaller angle. If the vectors are not coplanar, the test is based on the projection of the test vector into the plane of the other two vectors.

Zero testing is untoleranced, and is biased to all parallel conditions "false". That is, if any pair of the input vectors is parallel or antiparallel, the mathematical answer is false. Floating point tolerances will cause "nearby" cases to be unpredictable. It is assumed that if the caller considers the "parallel" cases important they will be checked explicitly.

Parameters
[in]vector0The first boundary vector.
[in]vector1The second boundary vector.
Returns
true if the test vector is within the angle.
bool IsZero ( )

checks if the vector has all zeros

double Magnitude ( ) const

Computes the magnitude of a vector.

Returns
The length of the vector
double MagnitudeSquared ( ) const

Computes the squared magnitude of a vector.

Returns
The squared magnitude of the vector.
double MagnitudeSquaredXY ( ) const

Computes the squared magnitude of the xy part of a vector.

Returns
The squared magnitude of the xy parts of the given vector.
double MagnitudeXY ( ) const

Computes the magnitude of the xy part of a vector.

Returns
The magnitude of the xy parts of the given vector.
double MaxAbs ( ) const

Finds the largest absolute value among the components of a vector.

Returns
The largest absolute value among vector coordinates.
void Multiply ( RotMatrixCR  matrix,
DVec3dCR  vector 
)

Returns the product of a matrix times a vector.

Parameters
[in]matrixThe matrix.
[in]vectorThe known vector.
void Multiply ( RotMatrixCR  matrix,
double  x,
double  y,
double  z 
)

Returns the product of a matrix times a vector, with the vector given as separate components.

Parameters
[in]matrixThe matrix to apply
[in]xThe x component of input vector
[in]yThe y component of input vector
[in]zThe z component of input vector
void MultiplyTranspose ( RotMatrixCR  matrix,
DVec3dCR  vector 
)

Returns the product of a matrix transpose times a vector.

Parameters
[in]matrixThe the matrix.
[in]vectorThe known vector.
void MultiplyTranspose ( RotMatrixCR  matrix,
double  x,
double  y,
double  z 
)

Returns the product P = [x,y,z]*M where M is the input matrix and P is the product vector.

Parameters
[in]matrixThe matrix to apply
[in]xThe x component
[in]yThe y component
[in]zThe z component
void Negate ( DVec3dCR  vector)

Computes a negated (opposite) vector.

Parameters
[in]vectorThe vector to be negated.
void Negate ( )

Negate a vector in place.

double Normalize ( DVec3dCR  vector)

Normalizes (scales) a vector to length 1.

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Parameters
[in]vectorThe vector to be normalized.
Returns
The length prior to normalization
double Normalize ( )

Replaces a vector by a unit vector in the same direction, and returns the original length.

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Returns
The length prior to normalization
double NormalizedCrossProduct ( DVec3dCR  vector1,
DVec3dCR  vector2 
)

Compute the normalized cross product of two vectors and return the length of the unnormalized cross product.

Parameters
[in]vector1The first vector
[in]vector2The second vector
Returns
The length of the original (prenormalization) cross product vector
double NormalizedDifference ( DPoint3dCR  target,
DPoint3dCR  origin 
)

Computes a unit vector in the direction of the difference of the vectors or vectors (Second parameter vector is subtracted from the first parameter vector, exactly as in the subtract function.)

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Parameters
[in]targetThe target point.
[in]originThe origin point.
Returns
The length of original difference vector.
double PlanarAngleTo ( DVec3dCR  vector2,
DVec3dCR  planeNormal 
) const

Computes the signed angle between the projection of two vectors onto a plane with given normal.

Parameters
[in]vector2The second vector
[in]planeNormalThe plane normal vector
Returns
The angle in plane
bool ProjectToPlane ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
DPoint2dR  uv 
) const

Find the projection of the instance vector to a plane defined by two vectors.

Parameters
[in]vectorUu-direction vector of the plane.
[in]vectorVv-direction vector of the plane.
[out]uvfractional coordinates on vectors.
Returns
false if plane vectors are not independent. In this case the method attempts to project to the longer plane vector, and sets the other fraction to 0. If that fails uv is 00.
bool ProjectToVector ( DVec3dCR  targetVector,
double &  fraction 
) const

Find the fraction at which the instance projects to a vector.

Parameters
[in]targetVectortarget vector.
[out]fractionprojection fraction
Returns
false if targetVector has zero length. In this case the fraction is zero.
void RotateXY ( DVec3dCR  vector,
double  theta 
)

Rotate a vector around the z axis.

Parameters
[in]vectorvector to rotate.
[in]thetaThe rotation angle.
void RotateXY ( double  theta)

Rotate a vector around the z axis.

Parameters
[in]thetaThe rotation angle.
bool SafeDivide ( DVec3dCR  vector,
double  denominator 
)

Try to divide each component of a vector by a scalar.

If the denominator near zero compared to any numerator component, return the original vector.

Parameters
[in]vectorThe initial vector.
[in]denominatorThe divisor.
Returns
true if division is numerically safe.
double SafeOneOverMagnitudeSquared ( double  defaultValue) const

Returns 1 over the squared magnitude, or caller supplied default if squared magnitude is too small.

void Scale ( DVec3dCR  vector,
double  scale 
)

Multiplies a vector by a scale factor.

Parameters
[in]vectorThe vector to be scaled.
[in]scaleThe scale factor.
void Scale ( double  scale)

Multiplies a vector (in place) by a scale factor.

Parameters
[in]scaleThe scale
double ScaleToLength ( DVec3dCR  vector,
double  length 
)

Scales a vector to specified length.

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Parameters
[in]vectorThe original vector.
[in]lengthThe requested length.
Returns
The length prior to scaling.
double ScaleToLength ( double  length)

Scales a vector to a specified length, and returns the prior length.

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Parameters
[in]lengthThe requested length
Returns
The length prior to scaling.
void SetComponent ( double  a,
int  index 
)

Set one of three components (x,y,z) of the vector.

Parameters
[in]aThe component value.
[in]indexSelects the the axis: 0=x, 1=y, 2=z, others cyclic.
double SignedAngleTo ( DVec3dCR  vector2,
DVec3dCR  orientationVector 
) const

Computes the signed angle from one vector to another, in the plane of the two vectors.

Initial computation using only the two vectors yields two possible angles depending on which side of the plane of the vectors is viewed. To choose which side to view, go on the side whose normal has a positive dot product with the orientation vector. This angle can be between -pi and +pi.

Parameters
[in]vector2The second vector
[in]orientationVectorThe vector used to determine orientation.
Returns
The signed angle
double SizedCrossProduct ( DVec3dCR  vector1,
DVec3dCR  vector2,
double  productLength 
)

Computes the cross product of the two parameter vectors and scales it to a given length.

The scaled vector is stored as the product vector, and the length of the original cross product vector is returned.

Parameters
[in]vector1The first vector
[in]vector2The second vector
[in]productLengthThe Desired length
Returns
The The length of unscaled cross product.
double SmallerUnorientedAngleTo ( DVec3dCR  vector2) const

Returns the angle between two vectors, choosing the smaller of the two possible angles when both the vectors and their negations are considered.

This angle is between 0 and pi/2.

Parameters
[in]vector2The second vector
Returns
The angle between the vectors.
double SmallerUnorientedAngleToXY ( DVec3dCR  vector2) const

Returns the angle between two vectors, considering both the vectors and their negations and choosing the smaller.

This angle is between 0 and pi/2.

Parameters
[in]vector2The second vector
Returns
The angle between vectors.
void Subtract ( DVec3dCR  vector2)

Subtract two vectors, and return the result in place of the first.

Parameters
[in]vector2The vector to subtract.
void SumOf ( DVec3dCR  vector1,
DVec3dCR  vector2 
)

Compute the sum of two vectors.

Parameters
[in]vector1The the first vector
[in]vector2The second vector
void SumOf ( DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2 
)

Compute the sum of two vectors with scale factors.

Parameters
[in]vector1The the first vector
[in]scale1first scale
[in]vector2The second vector
[in]scale2second scale
void SumOf ( DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2,
DVec3dCR  vector3,
double  scale3 
)

Compute the sum of three vectors with scale factors.

Parameters
[in]vector1The the first vector
[in]scale1first scale
[in]vector2The second vector
[in]scale2second scale
[in]vector3The third vector
[in]scale3third scale
void SumOf ( DVec3dCR  origin,
DVec3dCR  vector,
double  scale 
)

Adds an origin and a scaled vector.

Parameters
[in]originOrigin for the sum.
[in]vectorThe vector to be added.
[in]scaleThe scale factor.
void SumOf ( DVec3dCR  origin,
DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2 
)

Adds an origin and two scaled vectors.

Parameters
[in]originThe origin.
[in]vector1The first direction vector
[in]scale1The first scale factor
[in]vector2The second direction vector
[in]scale2The second scale factor
void SumOf ( DVec3dCR  origin,
DVec3dCR  vector1,
double  scale1,
DVec3dCR  vector2,
double  scale2,
DVec3dCR  vector3,
double  scale3 
)

Adds an origin and three scaled vectors.

Parameters
[in]originThe origin.
[in]vector1The first direction vector
[in]scale1The first scale factor
[in]vector2The second direction vector
[in]scale2The second scale factor
[in]vector3The third direction vector
[in]scale3The third scale factor
double TripleProduct ( DVec3dCR  vector2,
DVec3dCR  vector3 
) const

Computes the triple product of three vectors.

The following are equivalent definitions of the triple product of three vectors V1, V2, and V3:

  • (V1 cross V2) dot V3
  • V1 dot (V2 cross V3)
  • The determinant of the 3x3 matrix with the three vectors as its columns.
  • The determinant of the 3x3 matrix with the three vectors as its rows.
  • The (signed)volume of the parallelepiped whose 4 vertices are at the origin and at the ends of the 3 vectors placed at the origin.
Parameters
[in]vector2The second vector.
[in]vector3The third vector.
Returns
The triple product
bool TryNormalize ( DVec3dCR  source,
double &  magnitude 
)

initialize this vector to unit vector in the direction of source.

Remarks
In the 0-length error case, the vector is set to (1,0,0) in the legacy microstation style.
Parameters
[in]sourceThe vector to be normalized.
[out]magnitudeThe orignal magnitude of the source vector;
Returns
true if the other vector length is large enough for DoubleOps::SafeDivide to compute 1/length.
bool UnitPerpendicularXY ( DVec3dCR  vector)

Compute a unit vector perpendicular to the xy parts of given vector.

Parameters
[in]vectorThe source vector
Returns
true if the input vector has nonzero length
static DVec3d UnitX ( )
static

unit X vector

References DVec3d::From().

static DVec3d UnitY ( )
static

unit Y vector

References DVec3d::From().

static DVec3d UnitZ ( )
static

unit Z vector

References DVec3d::From().

ValidatedDouble ValidatedFractionOfProjection ( DVec3dCR  vectorToProject,
double  defaultValue = 0.0 
) const

Returns fraction at which other projects onto this, in ValidatedDouble which records if the division was safe.

ValidatedDVec3d ValidatedNormalize ( ) const

return a (possibly invalid) unit vector in the direction of the calling instance.

void WeightedDifferenceCrossProduct ( DPoint4dCR  basePoint,
DPoint4dCR  target1,
DPoint4dCR  target2 
)

Form the cross product of the weighted differences from base poitn to two targets.

Parameters
[in]basePointThe common base point (second point for differences)
[in]target1The first target point.
[in]target2The second target point.
void WeightedDifferenceOf ( DPoint4dCR  hPoint1,
DPoint4dCR  hPoint2 
)

Scale each (homogeneous) point by the other's weight and subtract, i.e.

form (point1 * point2.w - point2 * point1.w). The weight term vanishes. Copy the xyz parts back as a vector.

Parameters
[in]hPoint1The first homogeneous point
[in]hPoint2The second homogeneous point.
void XyzOf ( DPoint4dCR  hPoint)

Sets the x,y, and z components of a DVec3d structure from the corresponding parts of a DPoint4d.

Weight part of DPoint4d is not used.

Parameters
[in]hPointThe homogeneous point

The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.