Class Mat
Matrix class for robotics. Simple matrix class for homogeneous operations.
Inherited Members
Namespace:RoboDk.API
Assembly: RoboDkApi.dll
Syntax
public class Mat
Constructors
|Improve this Doc View SourceMat(Mat)
Matrix class constructor for a 4x4 homogeneous matrix as a copy from another matrix
Declaration
public Mat(Mat pose)
Parameters
Type | Name | Description |
---|---|---|
Mat | pose |
Mat(double, double, double, double, double, double, double, double, double, double, double, double)
Matrix class constructor for a 4x4 homogeneous matrix
Declaration
public Mat(double nx, double ox, double ax, double tx, double ny, double oy, double ay, double ty, double nz, double oz, double az, double tz)
Parameters
Type | Name | Description |
---|---|---|
double | nx | Position [0,0] |
double | ox | Position [0,1] |
double | ax | Position [0,2] |
double | tx | Position [0,3] |
double | ny | Position [1,0] |
double | oy | Position [1,1] |
double | ay | Position [1,2] |
double | ty | Position [1,3] |
double | nz | Position [2,0] |
double | oz | Position [2,1] |
double | az | Position [2,2] |
double | tz | Position [2,3] |
Mat(double, double, double, double, double, double, double, double, double)
Matrix class constructor for a 3x3 homogeneous matrix
Declaration
public Mat(double nx, double ox, double ax, double ny, double oy, double ay, double nz, double oz, double az)
Parameters
Type | Name | Description |
---|---|---|
double | nx | |
double | ox | |
double | ax | |
double | ny | |
double | oy | |
double | ay | |
double | nz | |
double | oz | |
double | az |
Mat(double, double, double)
Matrix class constructor for a 4x1 vector [x,y,z,1]
Declaration
public Mat(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
double | x | x coordinate |
double | y | y coordinate |
double | z | z coordinate |
Mat(double[], bool)
Matrix class constructor for a double array. The array will be set as a column matrix. Example: RDK.AddCurve(new Mat(new double[6] {{0,0,0, 0,0,1}}));
Declaration
public Mat(double[] point, bool isPose = false)
Parameters
Type | Name | Description |
---|---|---|
double[] | point | Column array |
bool | isPose | if isPose is True then convert vector into a 4x4 Pose Matrix. |
Mat(double[,])
矩阵类构造函数为双arr的数组ays or a single column array (list of points) Example: RDK.AddCurve(new Mat(new double[4, 6] {{0,0,0, 0,0,1}, { 500, 0, 0, 0, 0, 1 }, { 500, 500, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 1 } })); RDK.AddPoints(new Mat(new double[6] {{0,0,0, 0,0,1}}));
Declaration
public Mat(double[,] point_list)
Parameters
Type | Name | Description |
---|---|---|
double[,] | point_list | 点(arra数组列表y of doubles) |
Mat(int, int)
Matrix class constructor for any size matrix
Declaration
public Mat(int rows, int cols)
Parameters
Type | Name | Description |
---|---|---|
int | rows | dimension 1 size (rows) |
int | cols | dimension 2 size (columns) |
Fields
|Improve this Doc View SourceL
Declaration
public Mat L
Field Value
Type | Description |
---|---|
Mat |
U
Declaration
public Mat U
Field Value
Type | Description |
---|---|
Mat |
Properties
|Improve this Doc View SourceCols
Declaration
public int Cols { get; }
Property Value
Type | Description |
---|---|
int |
this[int, int]
Declaration
public double this[int iRow, int iCol] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | iRow | |
int | iCol |
Property Value
Type | Description |
---|---|
double |
Rows
Declaration
public int Rows { get; }
Property Value
Type | Description |
---|---|
int |
Methods
|Improve this Doc View Sourceangle3(double[], double[])
Returns the angle in radians of two 3D vectors
Declaration
public static double angle3(double[] a, double[] b)
Parameters
Type | Name | Description |
---|---|---|
double[] | a | |
double[] | b |
Returns
Type | Description |
---|---|
double |
cross(double[], double[])
Returns the cross product of two 3D vectors
Declaration
public static double[] cross(double[] a, double[] b)
Parameters
Type | Name | Description |
---|---|---|
double[] | a | |
double[] | b |
Returns
Type | Description |
---|---|
double[] |
dot(double[], double[])
Returns the dot product of two 3D vectors
Declaration
public static double dot(double[] a, double[] b)
Parameters
Type | Name | Description |
---|---|---|
double[] | a | |
double[] | b |
Returns
Type | Description |
---|---|
double |
Duplicate()
Declaration
public Mat Duplicate()
Returns
Type | Description |
---|---|
Mat |
FromTxyzRxyz(double, double, double, double, double, double)
Calculates the pose from the position and euler angles ([x,y,z,rx,ry,rz] array) The result is the same as calling: H = transl(x,y,z)rotx(rxpi/180)roty(rypi/180)rotz(rzpi/180)
Declaration
public static Mat FromTxyzRxyz(double x, double y, double z, double rx, double ry, double rz)
Parameters
Type | Name | Description |
---|---|---|
double | x | |
double | y | |
double | z | |
double | rx | |
double | ry | |
double | rz |
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
FromTxyzRxyz(double[])
Calculates the pose from the position and euler angles ([x,y,z,rx,ry,rz] array) The result is the same as calling: H = transl(x,y,z)rotx(rxpi/180)roty(rypi/180)rotz(rzpi/180)
Declaration
public static Mat FromTxyzRxyz(double[] xyzwpr)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyzwpr |
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
FromUR(double[])
Calculates the pose from the position and euler angles ([x,y,z,r,p,w] vector) Note: The difference between FromUR and FromXYZWPR is that the first one uses radians for the orientation and the second one uses degres The result is the same as calling: H = transl(x,y,z)*rotx(rx)*roty(ry)*rotz(rz)
Declaration
public static Mat FromUR(double[] xyzwpr)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyzwpr | The position and euler angles array |
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
FromXYZRPW(double, double, double, double, double, double)
Calculates the pose from the position and euler angles ([x,y,z,r,p,w] vector) The result is the same as calling: H = transl(x,y,z)rotz(wpi/180)roty(ppi/180)rotx(rpi/180)
Declaration
public static Mat FromXYZRPW(double x, double y, double z, double r, double p, double w)
Parameters
Type | Name | Description |
---|---|---|
double | x | |
double | y | |
double | z | |
double | r | |
double | p | |
double | w |
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
FromXYZRPW(double[])
Calculates the pose from the position and euler angles ([x,y,z,r,p,w] vector)
Declaration
public static Mat FromXYZRPW(double[] xyzwpr)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyzwpr |
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
GetCol(int)
Declaration
public Mat GetCol(int k)
Parameters
Type | Name | Description |
---|---|---|
int | k |
Returns
Type | Description |
---|---|
Mat |
Identity4x4()
Returns an identity 4x4 matrix (homogeneous matrix)
Declaration
public static Mat Identity4x4()
Returns
Type | Description |
---|---|
Mat |
IdentityMatrix(int, int)
Declaration
public static Mat IdentityMatrix(int iRows, int iCols)
Parameters
Type | Name | Description |
---|---|---|
int | iRows | |
int | iCols |
Returns
Type | Description |
---|---|
Mat |
inv()
Returns the inverse of a homogeneous matrix (4x4 matrix)
Declaration
public Mat inv()
Returns
Type | Description |
---|---|
Mat | Homogeneous matrix (4x4) |
Is4x4()
Declaration
public bool Is4x4()
Returns
Type | Description |
---|---|
bool |
IsHomogeneous()
Check if the matrix is homogeneous (4x4)
Declaration
public bool IsHomogeneous()
Returns
Type | Description |
---|---|
bool |
isIdentity()
Check if it is a Homogeneous Identity matrix
Declaration
public bool isIdentity()
Returns
Type | Description |
---|---|
bool |
IsSquare()
Check if the matrix is square
Declaration
public bool IsSquare()
Returns
Type | Description |
---|---|
bool |
MultiplyMatSimple(Mat, Mat)
Declaration
public static Mat MultiplyMatSimple(Mat m1, Mat m2)
Parameters
Type | Name | Description |
---|---|---|
Mat | m1 | |
Mat | m2 |
Returns
Type | Description |
---|---|
Mat |
norm(double[])
Returns the norm of a 3D vector
Declaration
public static double norm(double[] p)
Parameters
Type | Name | Description |
---|---|---|
double[] | p |
Returns
Type | Description |
---|---|
double |
normalize3(double[])
Returns the unitary vector
Declaration
public static double[] normalize3(double[] p)
Parameters
Type | Name | Description |
---|---|---|
double[] | p |
Returns
Type | Description |
---|---|
double[] |
NormalizeMatrixString(string)
Declaration
public static string NormalizeMatrixString(string matStr)
Parameters
Type | Name | Description |
---|---|---|
string | matStr |
Returns
Type | Description |
---|---|
string |
Pos()
Returns the XYZ position of the Homogeneous matrix
Declaration
public double[] Pos()
Returns
Type | Description |
---|---|
double[] | XYZ position |
Rot3x3()
Returns the sub 3x3 matrix that represents the pose rotation
Declaration
public Mat Rot3x3()
Returns
Type | Description |
---|---|
Mat |
rotate(Mat, Mat)
Rotate a vector given a matrix (rotation matrix or homogeneous matrix)
Declaration
public static Mat rotate(Mat pose, Mat vector)
Parameters
Type | Name | Description |
---|---|---|
Mat | pose | 4x4 homogeneous matrix or 3x3 rotation matrix |
Mat | vector | 4x1 or 3x1 vector |
Returns
Type | Description |
---|---|
Mat |
rotx(double)
Return a X-axis rotation matrix | 1 0 0 0 | rotx(rx) = | 0 cos(rx) -sin(rx) 0 | | 0 sin(rx) cos(rx) 0 | | 0 0 0 1 |
Declaration
public static Mat rotx(double rx)
Parameters
Type | Name | Description |
---|---|---|
double | rx | rotation around X axis (in radians) |
Returns
Type | Description |
---|---|
Mat |
roty(double)
Return a Y-axis rotation matrix | cos(ry) 0 sin(ry) 0 | roty(ry) = | 0 1 0 0 | | -sin(ry) 0 cos(ry) 0 | | 0 0 0 1 |
Declaration
public static Mat roty(double ry)
Parameters
Type | Name | Description |
---|---|---|
double | ry | rotation around Y axis (in radians) |
Returns
Type | Description |
---|---|
Mat |
rotz(double)
Return a Z-axis rotation matrix | cos(rz) -sin(rz) 0 0 | rotz(rx) = | sin(rz) cos(rz) 0 0 | | 0 0 1 0 | | 0 0 0 1 |
Declaration
public static Mat rotz(double rz)
Parameters
Type | Name | Description |
---|---|---|
double | rz | rotation around Z axis (in radians) |
Returns
Type | Description |
---|---|
Mat |
SetCol(Mat, int)
Declaration
public void SetCol(Mat v, int k)
Parameters
Type | Name | Description |
---|---|---|
Mat | v | |
int | k |
setPos(double, double, double)
Sets the 4x4 position of the Homogeneous matrix
Declaration
public void setPos(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
double | x | X position |
double | y | Y position |
double | z | Z position |
setPos(double[])
Sets the 4x4 position of the Homogeneous matrix
Declaration
public void setPos(double[] xyz)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyz | XYZ position |
setVX(double[])
Sets the VX orientation vector of the Homogeneous matrix
Declaration
public void setVX(double[] xyz)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyz | VX orientation vector |
setVY(double[])
Sets the VY orientation vector of the Homogeneous matrix
Declaration
public void setVY(double[] xyz)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyz | VY orientation vector |
setVZ(double[])
Sets the VZ orientation vector of the Homogeneous matrix
Declaration
public void setVZ(double[] xyz)
Parameters
Type | Name | Description |
---|---|---|
double[] | xyz | VZ orientation vector |
ToDoubles()
Converts a matrix into a one-dimensional array of doubles
Declaration
public double[] ToDoubles()
Returns
Type | Description |
---|---|
double[] | one-dimensional array |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
|Improve this Doc View SourceToString(bool)
Returns the Matrix string (XYZWPR using the functino ToTxyzRxyz() or matrix values)
Declaration
public string ToString(bool string_as_xyzabc = true)
Parameters
Type | Name | Description |
---|---|---|
bool | string_as_xyzabc |
Returns
Type | Description |
---|---|
string |
ToTxyzRxyz()
Calculates the equivalent position and euler angles ([x,y,z,rx,ry,rz] array) of a pose Note: Pose = transl(x,y,z)rotx(rxpi/180)roty(rypi/180)rotz(rzpi/180) See also: FromTxyzRxyz()
Declaration
public double[] ToTxyzRxyz()
Returns
Type | Description |
---|---|
double[] | XYZWPR translation and rotation in mm and degrees |
ToUR()
Calculates the equivalent position and euler angles ([x,y,z,r,p,w] vector) of the given pose in Universal Robots format Note: The difference between ToUR and ToXYZWPR is that the first one uses radians for the orientation and the second one uses degres Note: transl(x,y,z)rotx(rxpi/180)roty(rypi/180)rotz(rzpi/180) See also: FromXYZRPW()
Declaration
public double[] ToUR()
Returns
Type | Description |
---|---|
double[] | XYZWPR translation and rotation in mm and radians |
ToXYZRPW()
Calculates the equivalent position and euler angles ([x,y,z,r,p,w] vector) of the given pose Note: transl(x,y,z)rotz(wpi/180)roty(ppi/180)rotx(rpi/180) See also: FromXYZRPW()
Declaration
public double[] ToXYZRPW()
Returns
Type | Description |
---|---|
double[] | XYZWPR translation and rotation in mm and degrees |
transl(double, double, double)
Return a translation matrix | 1 0 0 X | transl(X,Y,Z) = | 0 1 0 Y | | 0 0 1 Z | | 0 0 0 1 |
Declaration
public static Mat transl(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
double | x | translation along X (mm) |
double | y | translation along Y (mm) |
double | z | translation along Z (mm) |
Returns
Type | Description |
---|---|
Mat |
Transpose()
Transpose a matrix
Declaration
public Mat Transpose()
Returns
Type | Description |
---|---|
Mat |
Transpose(Mat)
Declaration
public static Mat Transpose(Mat m)
Parameters
Type | Name | Description |
---|---|---|
Mat | m |
Returns
Type | Description |
---|---|
Mat |
VX()
Returns the VX orientation vector of the Homogeneous matrix
Declaration
public double[] VX()
Returns
Type | Description |
---|---|
double[] | VX orientation vector |
VY()
Returns the VY orientation vector of the Homogeneous matrix
Declaration
公共双[]v ()
Returns
Type | Description |
---|---|
double[] | VY orientation vector |
VZ()
Returns the VZ orientation vector of the Homogeneous matrix
Declaration
public double[] VZ()
Returns
Type | Description |
---|---|
double[] | VZ orientation vector |
xyzijk_2_pose(double[], double[], double[])
Convert a point XYZ and IJK vector (Z axis) to a pose given a hint for the Y axis
Declaration
public static Mat xyzijk_2_pose(double[] point, double[] zaxis, double[] yaxis_hint = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | point | |
double[] | zaxis | |
double[] | yaxis_hint |
Returns
Type | Description |
---|---|
Mat |
ZeroMatrix(int, int)
Declaration
public static Mat ZeroMatrix(int iRows, int iCols)
Parameters
Type | Name | Description |
---|---|---|
int | iRows | |
int | iCols |
Returns
Type | Description |
---|---|
Mat |
Operators
|Improve this Doc View Sourceoperator +(Mat, Mat)
Declaration
public static Mat operator +(Mat m1, Mat m2)
Parameters
Type | Name | Description |
---|---|---|
Mat | m1 | |
Mat | m2 |
Returns
Type | Description |
---|---|
Mat |
operator *(Mat, Mat)
Declaration
public static Mat operator *(Mat m1, Mat m2)
Parameters
Type | Name | Description |
---|---|---|
Mat | m1 | |
Mat | m2 |
Returns
Type | Description |
---|---|
Mat |
operator *(Mat, double[])
Declaration
public static double[] operator *(Mat m, double[] n)
Parameters
Type | Name | Description |
---|---|---|
Mat | m | |
double[] | n |
Returns
Type | Description |
---|---|
double[] |
operator *(double, Mat)
Declaration
public static Mat operator *(double n, Mat m)
Parameters
Type | Name | Description |
---|---|---|
double | n | |
Mat | m |
Returns
Type | Description |
---|---|
Mat |
operator -(Mat, Mat)
Declaration
public static Mat operator -(Mat m1, Mat m2)
Parameters
Type | Name | Description |
---|---|---|
Mat | m1 | |
Mat | m2 |
Returns
Type | Description |
---|---|
Mat |
operator -(Mat)
Declaration
public static Mat operator -(Mat m)
Parameters
Type | Name | Description |
---|---|---|
Mat | m |
Returns
Type | Description |
---|---|
Mat |