Rotations/Transformations
VectorTransform
Transforms a vector into a different reference frame.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | m | double* | Pointer to matrix [4x4] |
In | in | double* | Pointer to vector [4x1] |
Out | out | double* | Pointer to calculated vector [4x1] |
Return | BOOL | Always 0 |
Usage
plcbit VectorTransform(double* m, double* in, double* out);
VectorTransfromX
Multiplies a vector of any size by a square matrix of the same.
Direction | Name | Type | Description |
---|---|---|---|
In | m | double* | Pointer to a matrix [sizexsize] |
In | in | double* | Pointer to vector [sizex1] |
In | size | INT | Length of vector and size of matrix |
Out | out | double* | Pointer to calculated vector [sizex1] |
Return | BOOL | Always 0 |
Usage
plcbit VectorTransformX(double* m, double* in, double* out, signed short size);
NormalTransform
Transforms a vector into a different reference frame and then normalizes the vector to be a unit vector.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | m | double* | Pointer to matrix [4x4] |
In | in | double* | Pointer to vector [4x1] |
Out | out | double* | Pointer to calculated unit vector [4x1] |
Return | BOOL | Always 0 |
Usage
plcbit NormalTransform(double* m, double* in, double* out);
MatrixRotate (individual)
There are 6 individual MatrixRotate functions: 3 for X/Y/Z about the world axes and 3 for X/Y/Z about the body axes.
A rotation is applied by multiplying a rotation matrix built from the input angle, and the input transformation matrix. Pre-multiplying will rotate around the world axis and post-multiplying will rotate around the body axis.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | Angle | double | Angle to rotate the matrix by |
In | In | double* | Pointer to matrix [4x4] to be rotated |
Out | Out | double* | Pointer to matrix [4x4] after rotation |
Return | BOOL | Always 0 |
Usage
Rotate a transformation matrix about the world X axis.
plcbit MatrixRotateX(double Angle, double* In, double* Out);
Rotate a transformation matrix about the body Z axis.
plcbit MatrixRotateZB(double Angle, double* In, double* Out);
MatrixRotate (multiple)
Does a series of MatrixRotates around the body axes based on the given AngleType.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | AngleType | ANGLE_TYPES | Euler angle order |
In | Angles | Trans_Orientation_typ | Angles to rotate the matrix by |
In | In | double* | Pointer to matrix [4x4] to be rotated |
Out | Out | double* | Pointer to matrix [4x4] after rotation |
Return | BOOL | 0 on success, 1 if the angle type is not implemented or an addresses is invalid |
Usage
Rotate a transformation matrix in the body frame by Angles by applying them in AngleType Euler angle order.
plcbit MatrixRotate(enum ANGLE_TYPES AngleType, Trans_Orientation_typ Angles, double* In, double* Out);
MatrixTranslate
Adds the X, Y, and Z values to the corresponding translation components of the transformation matrix. It is possible to translate along the world frame axes or the body axes.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | In | double* | Pointer to matrix [4x4] |
Out | Out | double* | Pointer to translated matrix [4x4] |
In | X | double | Amount to translate matrix by in X |
In | Y | double | Amount to translate matrix by in Y |
In | Z | double | Amount to translate matrix by in Z |
Return | BOOL | Always 0 |
Usage
plcbit MatrixTranslate(double* In, double* Out, double X, double Y, double Z);
plcbit MatrixTranslateB(double* In, double* Out, double X, double Y, double Z);
DecompositionRotationMatrix
Converts a 4x4 transformation matrix into a position offset and a set of euler angles.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | M | UDINT | Pointer to the transformation matrix [4x4] |
In | Angle_Type | USINT | Euler angle order |
In | Angle_ext | UDINT | Pointer to the current ABC rotation [1x3] |
Out | X, Y, Z | LREAL | Calculated cartesian offsets |
Out | A, B, C | LREAL | Calculated Euler angles |
Out | Rot_X, Rot_Y, Rot_Z | LREAL[2] | Arrays of both Euler angle solutions |
Usage
void DecomposeRotationMatrix(struct DecomposeRotationMatrix* inst);
DecompRotMat
Wrapper function to convert a 4x4 transformation matrix into a position offset and a set of euler angles.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | M | UDINT | Pointer to the transformation matrix [4x4] |
In | AngleType | UDINT | Euler angle order |
In | ApproxAngles | UDINT | Pointer to the current ABC rotation [1x3] |
Out | Angles | UDINT | Pointer to calculated Euler angles in AngleType order [1x3] |
Out | Origin | UDINT | Pointer to calculated cartesian offset [1x3] |
Return | BOOL | Always 0 |
Example
plcbit DecompRotMat(unsigned long M, unsigned long AngleType, unsigned long ApproxAngles, unsigned long Angles, unsigned long Origin);
CoordToGlobal
This function is depreciated.
Transforms a position in a frame to a global position.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | AngleType | USINT | Euler angle order |
In | Frame | double* | Pointer to a matrix [4x4] |
In | in | double* | Pointer to a XYZ offset in the input frame [1x3] |
Out | out | double* | Pointer to the calculated global XYZ offset [1x3] |
Return | BOOL | Always 0 |
Usage
plcbit CoordToGlobal(unsigned char AngleType, double* Frame, double* in, double* out);
CoordToLocal
This function is depreciated.
Transforms a global position into a frame.
Parameters
Direction | Name | Type | Description |
---|---|---|---|
In | AngleType | USINT | Euler angle order |
In | Frame | double* | Pointer to a matrix [4x4] |
In | in | double* | Pointer to a global XYZ offset [1x3] |
Out | out | double* | Pointer to the calculated XYZ offset in the input frame [1x3] |
Return | BOOL | Always 0 |
Usage
plcbit CoordToLocal(unsigned char AngleType, double* Frame, double* in, double* out);