Cancel
Showing results for
Did you mean:

# Get a coordinate system Matrix relative to another coordinate system

Solution Partner Genius

Hi all,

I have an assembly with 3 coordinate systems :

Base - the standard for assembly files

Global - the one I need to use as reference

Equip - the one I need to find the matrix relative to global

I manage to create the 2 4x4 matrix for Global and Equip relative to Base, what I need now is to find the matrix of Equip relative to Global.

Can't find how to get this in vb.net, help please.

Romuald BERTIN
2 REPLIES

# Re: Get a coordinate system Matrix relative to another coordinate system

Valued Contributor

This function is not provided in the SDK.  I ended up locating a general matrix library, specializing it for 4x4, and then the answer is something like:

relativeMat = firstMat / secondMat;

I'm not fully happy with what I've got assembled, but I am thinking to publish eventually in community extensions.

# Re: Get a coordinate system Matrix relative to another coordinate system

Solution Partner Genius

Thanks AlanBaljeu

I manage to make this working , using the following code where matrix_Equip, Ori_Input_Equip, matrix_Navire and Ori_Input_Navire are information aboiut position of the Global and Equip coordinate system relative to Base.

```        Dim matrix_Local As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)
matrix_Local.Item(0, 0) = matrix_Equip.Item(0, 0)
matrix_Local.Item(0, 1) = matrix_Equip.Item(0, 1)
matrix_Local.Item(0, 2) = matrix_Equip.Item(0, 2)
matrix_Local.Item(0, 3) = 0
matrix_Local.Item(1, 0) = matrix_Equip.Item(1, 0)
matrix_Local.Item(1, 1) = matrix_Equip.Item(1, 1)
matrix_Local.Item(1, 2) = matrix_Equip.Item(1, 2)
matrix_Local.Item(1, 3) = 0
matrix_Local.Item(2, 0) = matrix_Equip.Item(2, 0)
matrix_Local.Item(2, 1) = matrix_Equip.Item(2, 1)
matrix_Local.Item(2, 2) = matrix_Equip.Item(2, 2)
matrix_Local.Item(2, 3) = 0
matrix_Local.Item(3, 0) = Ori_Input_Equip.X
matrix_Local.Item(3, 1) = Ori_Input_Equip.Y
matrix_Local.Item(3, 2) = Ori_Input_Equip.Z
matrix_Local.Item(3, 3) = 1

Dim matrix_Local_Trans As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)
matrix_Local_Trans = matrix_Local.Transpose()

Dim matrix_Global As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)
matrix_Global.Item(0, 0) = matrix_Navire.Item(0, 0)
matrix_Global.Item(0, 1) = matrix_Navire.Item(0, 1)
matrix_Global.Item(0, 2) = matrix_Navire.Item(0, 2)
matrix_Global.Item(0, 3) = 0
matrix_Global.Item(1, 0) = matrix_Navire.Item(1, 0)
matrix_Global.Item(1, 1) = matrix_Navire.Item(1, 1)
matrix_Global.Item(1, 2) = matrix_Navire.Item(1, 2)
matrix_Global.Item(1, 3) = 0
matrix_Global.Item(2, 0) = matrix_Navire.Item(2, 0)
matrix_Global.Item(2, 1) = matrix_Navire.Item(2, 1)
matrix_Global.Item(2, 2) = matrix_Navire.Item(2, 2)
matrix_Global.Item(2, 3) = 0
matrix_Global.Item(3, 0) = Ori_Input_Navire.X
matrix_Global.Item(3, 1) = Ori_Input_Navire.Y
matrix_Global.Item(3, 2) = Ori_Input_Navire.Z
matrix_Global.Item(3, 3) = 1

Dim matrix_Global_Trans As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)
matrix_Global_Trans = matrix_Global.Transpose()

Dim matrix_Global_Trans_Inv As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)
matrix_Global_Trans_Inv = matrix_Global_Trans.Inverse

Dim matrix_Result As New MathNet.Numerics.LinearAlgebra.Double.DenseMatrix(4, 4)

matrix_Result = matrix_Global_Trans_Inv.Multiply(matrix_Local_Trans)```

Romuald BERTIN