Camillo
Automotive
- May 31, 2022
- 6
Hello,
I have various assemblies (products) made up with multiple products. For some of them I have the correct mutual coordinates and want to check whether these products are located properly.
For example:
That's why I would like to obtain (XYZ, YPR) in reference to Absolute (0,0,0,0,0,0) on each of these products.
I found nice solution there: where user Favero Osvaldo prepared an transform matrix:
to obtain XYZ in a loop until top level is reached. It works for me nice pretty nice however I also need angles. I know that
In positions 0-9 stores informations about angles. I expanded his code by multiplying two matrices 3x3 (desired Product or resulting Matrix after few loops and inverse orientation of parent.
Code snippet for it looks in that way:
Then I use that final matrix for few trigonometric functions to obtain YPR in degrees. It works for me as long as EVERY parent of the desired product has YPR=0,0,0 - in other words, any parent cannot be rotated, otherwise I am getting completely wrong values.
I tried to add vCoord(0-9) or aRel(0-9) to each of these values (like it was done for XYZ) but I can't obtain proper angles matrix in any way.
How can i get the rotation angles of the product with respect to the absolute if his parent products are rotated too? Maybe is there any simpler method like GetXYZ and GetYPR methods for tags?
Thank you.
I have various assemblies (products) made up with multiple products. For some of them I have the correct mutual coordinates and want to check whether these products are located properly.
For example:
Product1 -+
---------- Product1.1
---------- Product1.2
---------- Product1.3 -+
----------------------- Product1.3.1 -+
-------------------------------------- Product1.3.1.1
-------------------------------------- Product1.3.1.2
---------- Product1.4
That's why I would like to obtain (XYZ, YPR) in reference to Absolute (0,0,0,0,0,0) on each of these products.
I found nice solution there: where user Favero Osvaldo prepared an transform matrix:
Code:
aAbs(0) = vCoord(9) + aInv(0) * aRel(0) + aInv(1) * aRel(1) + aInv(2) * aRel(2)
aAbs(1) = vCoord(10) + aInv(3) * aRel(0) + aInv(4) * aRel(1) + aInv(5) * aRel(2)
aAbs(2) = vCoord(11) + aInv(6) * aRel(0) + aInv(7) * aRel(1) + aInv(8) * aRel(2)
to obtain XYZ in a loop until top level is reached. It works for me nice pretty nice however I also need angles. I know that
Code:
vProduct.Position.GetComponents vCoord
In positions 0-9 stores informations about angles. I expanded his code by multiplying two matrices 3x3 (desired Product or resulting Matrix after few loops and inverse orientation of parent.
Code snippet for it looks in that way:
Code:
[COLOR=#4E9A06]' [aRel(0) aRel(1) aRel(2)] [aInv(0) aInv(1) aInv(2)][/color]
[COLOR=#4E9A06]' [aRel(3) aRel(4) aRel(5)] * [aInv(3) aInv(4) aInv(5)][/color]
[COLOR=#4E9A06]' [aRel(6) aRel(7) aRel(8)] [aInv(6) aInv(7) aInv(8)][/color]
aAbs(0) = aRel(0)*aInv(0) + aRel(1)*aInv(3) + aRel(2)*aInv(6)
aAbs(1) = aRel(0)*aInv(1) + aRel(1)*aInv(4) + aRel(2)*aInv(7)
aAbs(2) = aRel(0)*aInv(2) + aRel(1)*aInv(5) + aRel(2)*aInv(8)
aAbs(3) = aRel(3)*aInv(0) + aRel(4)*aInv(3) + aRel(5)*aInv(6)
aAbs(4) = aRel(3)*aInv(1) + aRel(4)*aInv(4) + aRel(5)*aInv(7)
aAbs(5) = aRel(3)*aInv(2) + aRel(4)*aInv(5) + aRel(5)*aInv(8)
aAbs(6) = aRel(6)*aInv(0) + aRel(7)*aInv(3) + aRel(8)*aInv(6)
aAbs(7) = aRel(6)*aInv(1) + aRel(7)*aInv(4) + aRel(8)*aInv(7)
aAbs(8) = aRel(6)*aInv(2) + aRel(7)*aInv(5) + aRel(8)*aInv(8)
aAbs(9) = vCoord(9) + aRel(9)*aInv(0) + aRel(10)*aInv(3) + aRel(11)*aInv(6)
aAbs(10) = vCoord(10) + aRel(9)*aInv(1) + aRel(10)*aInv(4) + aRel(11)*aInv(7)
aAbs(11) = vCoord(11) + aRel(9)*aInv(2) + aRel(10)*aInv(5) + aRel(11)*aInv(8)
Then I use that final matrix for few trigonometric functions to obtain YPR in degrees. It works for me as long as EVERY parent of the desired product has YPR=0,0,0 - in other words, any parent cannot be rotated, otherwise I am getting completely wrong values.
I tried to add vCoord(0-9) or aRel(0-9) to each of these values (like it was done for XYZ) but I can't obtain proper angles matrix in any way.
How can i get the rotation angles of the product with respect to the absolute if his parent products are rotated too? Maybe is there any simpler method like GetXYZ and GetYPR methods for tags?
Thank you.