Calculate the inner product of two vectors.
void InnerProduct(const XyzVector& vector1, const XyzVector& vector2, DOUBLE64& product)
vector1
[IN] multiplicand. See XyzVector
vector2
[IN] multiplier. See XyzVector
product
[OUT] result of the inner product.
None
DOUBLE64 a = 0.0;
VectorMath::InnerProduct({ 1, 2, 3 }, { 4, 5, 6 }, a);
std::cout << a << std::endl;
Output
32
Calculate the cross product of two vectors.
void CrossProduct(const XyzVector& vector1, const XyzVector& vector2, XyzVector& product)
vector1
[IN] multiplicand. See XyzVector
vector2
[IN] multiplier. See XyzVector
product
[OUT] result of the cross product. See XyzVector
None
XyzVector v1 = { 1, 0, 0 };
VectorMath::CrossProduct({ 1, 0, 0 }, { 0, 1, 0 }, v1);
std::cout << v1 << std::endl;
Output
X: 0
Y: 0
Z: 1
Calculate the inverse of a frame.
void InvertFrame(const EulerMatrix& frame, EulerMatrix& inverseFrame)
frame
[IN] The frame to invert. See EulerMatrix
inverseFrame
[OUT] The inverse of the frame. See EulerMatrix
None
EulerMatrix frame = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
EulerMatrix inverseFrame;
FrameMath::InvertFrame(frame, inverseFrame);
std::cout << inverseFrame << std::endl;
Output
nx: 1, ox: 0, ax: 0, px: -0
ny: 0, oy: 1, ay: 0, py: -0
nz: 0, oz: 0, az: 1, pz: -0
Rotate a frame about an axis by a specified angle.
void RotateFrame(const EulerMatrix& org_frame, const XyzVector& rotationVector, DOUBLE64 angle, EulerMatrix& rotatedFrame)
org_frame
[IN] Origin frame. See EulerMatrix
rotationVector
[IN] The vector to rotate about. See XyzVector
angle
[IN] The angle to rotate by.
rotatedFrame
[OUT] The rotated frame. See EulerMatrix
None
EulerMatrix frame = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
EulerMatrix rotatedFrame;
FrameMath::RotateFrame(frame, { 0, 0, 1 }, 90, rotatedFrame);
std::cout << rotatedFrame << std::endl;
Output
nx: 6.12323e-17, ox: -1, ax: 0, px: 0
ny: 1, oy: 6.12323e-17, ay: 0, py: 0
nz: 0, oz: 0, az: 1, pz: 0
Convert a frame to ZYX Euler angles.
void FrameToZYXeuler(const EulerMatrix& frame, CoordinateArray& coord);
frame
[IN] The frame to convert. See EulerMatrix
coord
[OUT] Converted angles.
None
EulerMatrix frame = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
CoordinateArray coord;
FrameMath::FrameToZYXeuler(frame, coord);
for (INT32 i = 0; i < coord.size(); i++)
{
std::cout << coord[i] << std::endl;
}
return 0;
Output
0
0
0
0
-0
0
-9.25596e+61
-9.25596e+61
Multiply two frames together.
void MultiplyFrames(const EulerMatrix& f1, const EulerMatrix& f2, EulerMatrix& productFrame);
f1
[IN] multiplicand. See EulerMatrix
f2
[IN] multiplier. See EulerMatrix
productFrame
[OUT] result of the multiplication.
None
EulerMatrix frame1 = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
EulerMatrix frame2 = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
EulerMatrix productFrame;
FrameMath::MultiplyFrames(frame1, frame2, productFrame);
std::cout << productFrame << std::endl;
Output
nx: 1, ox: 0, ax: 0, px: 0
ny: 0, oy: 1, ay: 0, py: 0
nz: 0, oz: 0, az: 1, pz: 0
Convert ZYX Euler angles to a frame.
void ZYXeulerToFrame(const CoordinateArray& coord, EulerMatrix& frame);
coord
[IN] The angles to convert.
frame
[OUT] Converted frame. See EulerMatrix
None
CoordinateArray coord = { 0, 0, 20, 0, 0, 0 };
EulerMatrix frame;
FrameMath::ZYXeulerToFrame(coord, frame);
std::cout << frame << std::endl;
Output
nx: 1, ox: 0, ax: 0, px: 0
ny: 0, oy: 1, ay: 0, py: 0
nz: -0, oz: 0, az: 1, pz: 20
Set the identity matrix in a frame.
void SetIdentityMatrixInFrame(EulerMatrix& frame);
frame
[OUT] The frame to set the identity matrix in. See EulerMatrix
None
EulerMatrix frame{};
std::cout << "Frame before call to SetIdentityMatrixInFrame\n" << frame << std::endl;
FrameMath::SetIdentityMatrixInFrame(frame);
std::cout << "Frame after call to SetIdentityMatrixInFrame\n" << frame << std::endl;
Output
Frame before call to SetIdentityMatrixInFrame
nx: 0, ox: 0, ax: 0, px: 0
ny: 0, oy: 0, ay: 0, py: 0
nz: 0, oz: 0, az: 0, pz: 0
Frame after call to SetIdentityMatrixInFrame
nx: 1, ox: 0, ax: 0, px: 0
ny: 0, oy: 1, ay: 0, py: 0
nz: 0, oz: 0, az: 1, pz: 0