Table of Contents

Class Mat

Namespace
RoboDk.API
Assembly
RoboDkApi.dll

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

x double

x coordinate

y double

y coordinate

z double

z coordinate

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

nx double
ox double
ax double
ny double
oy double
ay double
nz double
oz double
az double

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 double

Position [0,0]

ox double

Position [0,1]

ax double

Position [0,2]

tx double

Position [0,3]

ny double

Position [1,0]

oy double

Position [1,1]

ay double

Position [1,2]

ty double

Position [1,3]

nz double

Position [2,0]

oz double

Position [2,1]

az double

Position [2,2]

tz double

Position [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

point double[]

Column array

isPose bool

if isPose is True then convert vector into a 4x4 Pose Matrix.

Mat(int, int)

Matrix class constructor for any size matrix

public Mat(int rows, int cols)

Parameters

rows int

dimension 1 size (rows)

cols int

dimension 2 size (columns)

Fields

L

public Mat L

Field Value

Mat

U

public Mat U

Field Value

Mat

Properties

Cols

public int Cols { get; }

Property Value

int

this[int, int]

public double this[int iRow, int iCol] { get; set; }

Parameters

iRow int
iCol int

Property Value

double

Rows

public int Rows { get; }

Property Value

int

Methods

ConcatenateHorizontal(Mat)

public Mat ConcatenateHorizontal(Mat matrix)

Parameters

matrix Mat

Returns

Mat

ConcatenateVertical(Mat)

public Mat ConcatenateVertical(Mat matrix)

Parameters

matrix Mat

Returns

Mat

Duplicate()

public Mat Duplicate()

Returns

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)

public static Mat FromTxyzRxyz(double x, double y, double z, double rx, double ry, double rz)

Parameters

x double
y double
z double
rx double
ry double
rz double

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

x double
y double
z double
r double
p double
w double

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

Mat

Identity4x4()

Returns an identity 4x4 matrix (homogeneous matrix)

public static Mat Identity4x4()

Returns

Mat

IdentityMatrix(int, int)

public static Mat IdentityMatrix(int iRows, int iCols)

Parameters

iRows int
iCols int

Returns

Mat

Is4x4()

public bool Is4x4()

Returns

bool

IsHomogeneous()

Check if the matrix is homogeneous (4x4)

public bool IsHomogeneous()

Returns

bool

IsSquare()

Check if the matrix is square

public bool IsSquare()

Returns

bool

MultiplyMatSimple(Mat, Mat)

public static Mat MultiplyMatSimple(Mat m1, Mat m2)

Parameters

m1 Mat
m2 Mat

Returns

Mat

NormalizeMatrixString(string)

public static string NormalizeMatrixString(string matStr)

Parameters

matStr string

Returns

string

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 Mat

Reference pose

x double

Translation along the Tool X axis (mm)

y double

Translation along the Tool Y axis (mm)

z double

Translation along the Tool Z axis (mm)

rx double

Rotation around the Tool X axis (deg) (optional)

ry double

Rotation around the Tool Y axis (deg) (optional)

rz double

Rotation 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 Mat

Reference pose

x double

Translation along the Tool X axis (mm)

y double

Translation along the Tool Y axis (mm)

z double

Translation along the Tool Z axis (mm)

rx double

Rotation around the Tool X axis (deg) (optional)

ry double

Rotation around the Tool Y axis (deg) (optional)

rz double

Rotation 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

Mat

RotationPose()

public Mat RotationPose()

Returns

Mat

SaveCSV(string)

public void SaveCSV(string filename)

Parameters

filename string

SaveMat(string, string)

public void SaveMat(string filename, string separator = ",")

Parameters

filename string
separator string

SetCol(Mat, int)

public void SetCol(Mat v, int k)

Parameters

v Mat
k int

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

string

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

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()

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

Mat

Transpose()

Transpose a matrix

public Mat Transpose()

Returns

Mat

Transpose(Mat)

public static Mat Transpose(Mat m)

Parameters

m Mat

Returns

Mat

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

iRows int
iCols int

Returns

Mat

angle3(double[], double[])

Returns the angle in radians of two 3D vectors

public static double angle3(double[] a, double[] b)

Parameters

a double[]
b double[]

Returns

double

cross(double[], double[])

Returns the cross product of two 3D vectors

public static double[] cross(double[] a, double[] b)

Parameters

a double[]
b double[]

Returns

double[]

dot(double[], double[])

Returns the dot product of two 3D vectors

public static double dot(double[] a, double[] b)

Parameters

a double[]
b double[]

Returns

double

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

bool

norm(double[])

Returns the norm of a 3D vector

public static double norm(double[] p)

Parameters

p double[]

Returns

double

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

pose Mat

4x4 homogeneous matrix or 3x3 rotation matrix

vector Mat

4x1 or 3x1 vector

Returns

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 |

public static Mat rotx(double rx)

Parameters

rx double

rotation around X axis (in radians)

Returns

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 |

public static Mat roty(double ry)

Parameters

ry double

rotation around Y axis (in radians)

Returns

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 |

public static Mat rotz(double rz)

Parameters

rz double

rotation around Z axis (in radians)

Returns

Mat

setPos(double, double, double)

Sets the 4x4 position of the Homogeneous matrix

public void setPos(double x, double y, double z)

Parameters

x double

X position

y double

Y position

z double

Z position

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

x double

translation along X (mm)

y double

translation along Y (mm)

z double

translation along Z (mm)

Returns

Mat

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

point double[]
zaxis double[]
yaxis_hint double[]

Returns

Mat

Operators

operator +(Mat, Mat)

public static Mat operator +(Mat m1, Mat m2)

Parameters

m1 Mat
m2 Mat

Returns

Mat

operator *(Mat, Mat)

public static Mat operator *(Mat m1, Mat m2)

Parameters

m1 Mat
m2 Mat

Returns

Mat

operator *(Mat, double[])

public static double[] operator *(Mat m, double[] n)

Parameters

m Mat
n double[]

Returns

double[]

operator *(double, Mat)

public static Mat operator *(double n, Mat m)

Parameters

n double
m Mat

Returns

Mat

operator -(Mat, Mat)

public static Mat operator -(Mat m1, Mat m2)

Parameters

m1 Mat
m2 Mat

Returns

Mat

operator -(Mat)

public static Mat operator -(Mat m)

Parameters

m Mat

Returns

Mat