Class Mat
Matrix class for robotics. Simple matrix class for homogeneous operations.
public class Mat
- Inheritance
- Mat
- Inherited Members
Constructors
Mat(Mat)
Matrix class constructor for a 4x4 homogeneous matrix as a copy from another matrix
public Mat(Mat pose)
Parameters
pose
Mat
Mat(double, double, double)
Matrix class constructor for a 4x1 vector [x,y,z,1]
public Mat(double x, double y, double z)
Parameters
Mat(double, double, double, double, double, double, double, double, double)
Matrix class constructor for a 3x3 homogeneous matrix
public Mat(double nx, double ox, double ax, double ny, double oy, double ay, double nz, double oz, double az)
Parameters
Mat(double, double, double, double, double, double, double, double, double, double, double, double)
Matrix class constructor for a 4x4 homogeneous matrix
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
nx
doublePosition [0,0]
ox
doublePosition [0,1]
ax
doublePosition [0,2]
tx
doublePosition [0,3]
ny
doublePosition [1,0]
oy
doublePosition [1,1]
ay
doublePosition [1,2]
ty
doublePosition [1,3]
nz
doublePosition [2,0]
oz
doublePosition [2,1]
az
doublePosition [2,2]
tz
doublePosition [2,3]
Mat(double[,])
Matrix class constructor for a double array of arrays 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}}));
public Mat(double[,] point_list)
Parameters
point_list
double[,]List of points (array of array of doubles)
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}}));
public Mat(double[] point, bool isPose = false)
Parameters
Mat(int, int)
Matrix class constructor for any size matrix
public Mat(int rows, int cols)
Parameters
Fields
L
public Mat L
Field Value
U
public Mat U
Field Value
Properties
Cols
public int Cols { get; }
Property Value
this[int, int]
public double this[int iRow, int iCol] { get; set; }
Parameters
Property Value
Rows
public int Rows { get; }
Property Value
Methods
ConcatenateHorizontal(Mat)
public Mat ConcatenateHorizontal(Mat matrix)
Parameters
matrix
Mat
Returns
ConcatenateVertical(Mat)
public Mat ConcatenateVertical(Mat matrix)
Parameters
matrix
Mat
Returns
Duplicate()
public Mat Duplicate()
Returns
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)
public static Mat FromTxyzRxyz(double x, double y, double z, double rx, double ry, double rz)
Parameters
Returns
- 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)
public static Mat FromTxyzRxyz(double[] xyzwpr)
Parameters
xyzwpr
double[]
Returns
- Mat
Homogeneous matrix (4x4)
FromUR(double[])
Calculates the pose from the position and uvw rotation angles ([x,y,z,u,v,w] vector)
public static Mat FromUR(double[] xyzwpr)
Parameters
xyzwpr
double[]The position and euler angles array
Returns
- 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)
public static Mat FromXYZRPW(double x, double y, double z, double r, double p, double w)
Parameters
Returns
- Mat
Homogeneous matrix (4x4)
FromXYZRPW(double[])
Calculates the pose from the position and euler angles ([x,y,z,r,p,w] vector)
public static Mat FromXYZRPW(double[] xyzwpr)
Parameters
xyzwpr
double[]
Returns
- Mat
Homogeneous matrix (4x4)
GetCol(int)
public Mat GetCol(int k)
Parameters
k
int
Returns
Identity4x4()
Returns an identity 4x4 matrix (homogeneous matrix)
public static Mat Identity4x4()
Returns
IdentityMatrix(int, int)
public static Mat IdentityMatrix(int iRows, int iCols)
Parameters
Returns
Is4x4()
public bool Is4x4()
Returns
IsHomogeneous()
Check if the matrix is homogeneous (4x4)
public bool IsHomogeneous()
Returns
IsSquare()
Check if the matrix is square
public bool IsSquare()
Returns
MultiplyMatSimple(Mat, Mat)
public static Mat MultiplyMatSimple(Mat m1, Mat m2)
Parameters
Returns
NormalizeMatrixString(string)
public static string NormalizeMatrixString(string matStr)
Parameters
matStr
string
Returns
Offset(Mat, double, double, double, double, double, double)
Calculates a relative target with respect to the reference frame coordinates.
public Mat Offset(Mat targetPose, double x, double y, double z, double rx = 0, double ry = 0, double rz = 0)
Parameters
targetPose
MatReference pose
x
doubleTranslation along the Tool X axis (mm)
y
doubleTranslation along the Tool Y axis (mm)
z
doubleTranslation along the Tool Z axis (mm)
rx
doubleRotation around the Tool X axis (deg) (optional)
ry
doubleRotation around the Tool Y axis (deg) (optional)
rz
doubleRotation around the Tool Z axis (deg) (optional)
Returns
- Mat
Returns relative target
Pos()
Returns the XYZ position of the Homogeneous matrix
public double[] Pos()
Returns
- double[]
XYZ position
RelTool(Mat, double, double, double, double, double, double)
Calculates a relative target with respect to the tool coordinates. This procedure has exactly the same behavior as ABB's RelTool instruction.
public Mat RelTool(Mat targetPose, double x, double y, double z, double rx = 0, double ry = 0, double rz = 0)
Parameters
targetPose
MatReference pose
x
doubleTranslation along the Tool X axis (mm)
y
doubleTranslation along the Tool Y axis (mm)
z
doubleTranslation along the Tool Z axis (mm)
rx
doubleRotation around the Tool X axis (deg) (optional)
ry
doubleRotation around the Tool Y axis (deg) (optional)
rz
doubleRotation around the Tool Z axis (deg) (optional)
Returns
- Mat
Returns relative target
Rot3x3()
Returns the sub 3x3 matrix that represents the pose rotation
public Mat Rot3x3()
Returns
RotationPose()
public Mat RotationPose()
Returns
SaveCSV(string)
public void SaveCSV(string filename)
Parameters
filename
string
SaveMat(string, string)
public void SaveMat(string filename, string separator = ",")
Parameters
SetCol(Mat, int)
public void SetCol(Mat v, int k)
Parameters
ToDoubles()
Converts a matrix into a one-dimensional array of doubles
public double[] ToDoubles()
Returns
- double[]
one-dimensional array
ToString()
public override string ToString()
Returns
ToString(bool)
Returns the Matrix string (XYZWPR using the functino ToTxyzRxyz() or matrix values)
public string ToString(bool string_as_xyzabc = true)
Parameters
string_as_xyzabc
bool
Returns
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()
public double[] ToTxyzRxyz()
Returns
- double[]
XYZWPR translation and rotation in mm and degrees
ToUR()
Calculates the equivalent position and euler angles ([x,y,z,u,v,w] vector) of the given pose in Universal Robots format The uvw values are the rotation vector
public double[] ToUR()
Returns
- 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()
public double[] ToXYZRPW()
Returns
- double[]
XYZWPR translation and rotation in mm and degrees
TranslationPose()
public Mat TranslationPose()
Returns
Transpose()
Transpose a matrix
public Mat Transpose()
Returns
Transpose(Mat)
public static Mat Transpose(Mat m)
Parameters
m
Mat
Returns
VX()
Returns the VX orientation vector of the Homogeneous matrix
public double[] VX()
Returns
- double[]
VX orientation vector
VY()
Returns the VY orientation vector of the Homogeneous matrix
public double[] VY()
Returns
- double[]
VY orientation vector
VZ()
Returns the VZ orientation vector of the Homogeneous matrix
public double[] VZ()
Returns
- double[]
VZ orientation vector
ZeroMatrix(int, int)
public static Mat ZeroMatrix(int iRows, int iCols)
Parameters
Returns
angle3(double[], double[])
Returns the angle in radians of two 3D vectors
public static double angle3(double[] a, double[] b)
Parameters
Returns
cross(double[], double[])
Returns the cross product of two 3D vectors
public static double[] cross(double[] a, double[] b)
Parameters
Returns
- double[]
dot(double[], double[])
Returns the dot product of two 3D vectors
public static double dot(double[] a, double[] b)
Parameters
Returns
inv()
Returns the inverse of a homogeneous matrix (4x4 matrix)
public Mat inv()
Returns
- Mat
Homogeneous matrix (4x4)
isIdentity()
Check if it is a Homogeneous Identity matrix
public bool isIdentity()
Returns
norm(double[])
Returns the norm of a 3D vector
public static double norm(double[] p)
Parameters
p
double[]
Returns
normalize3(double[])
Returns the unitary vector
public static double[] normalize3(double[] p)
Parameters
p
double[]
Returns
- double[]
rotate(Mat, Mat)
Rotate a vector given a matrix (rotation matrix or homogeneous matrix)
public static Mat rotate(Mat pose, Mat vector)
Parameters
Returns
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 |
public static Mat rotx(double rx)
Parameters
rx
doublerotation around X axis (in radians)
Returns
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 |
public static Mat roty(double ry)
Parameters
ry
doublerotation around Y axis (in radians)
Returns
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 |
public static Mat rotz(double rz)
Parameters
rz
doublerotation around Z axis (in radians)
Returns
setPos(double, double, double)
Sets the 4x4 position of the Homogeneous matrix
public void setPos(double x, double y, double z)
Parameters
setPos(double[])
Sets the 4x4 position of the Homogeneous matrix
public void setPos(double[] xyz)
Parameters
xyz
double[]XYZ position
setVX(double[])
Sets the VX orientation vector of the Homogeneous matrix
public void setVX(double[] xyz)
Parameters
xyz
double[]VX orientation vector
setVY(double[])
Sets the VY orientation vector of the Homogeneous matrix
public void setVY(double[] xyz)
Parameters
xyz
double[]VY orientation vector
setVZ(double[])
Sets the VZ orientation vector of the Homogeneous matrix
public void setVZ(double[] xyz)
Parameters
xyz
double[]VZ orientation vector
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 |
public static Mat transl(double x, double y, double z)
Parameters
Returns
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
public static Mat xyzijk_2_pose(double[] point, double[] zaxis, double[] yaxis_hint = null)
Parameters
Returns
Operators
operator +(Mat, Mat)
public static Mat operator +(Mat m1, Mat m2)
Parameters
Returns
operator *(Mat, Mat)
public static Mat operator *(Mat m1, Mat m2)
Parameters
Returns
operator *(Mat, double[])
public static double[] operator *(Mat m, double[] n)
Parameters
Returns
- double[]
operator *(double, Mat)
public static Mat operator *(double n, Mat m)
Parameters
Returns
operator -(Mat, Mat)
public static Mat operator -(Mat m1, Mat m2)
Parameters
Returns
operator -(Mat)
public static Mat operator -(Mat m)
Parameters
m
Mat