Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Where can I find the meaning of the number in the transform property from the API?

kevin_dolfingkevin_dolfing Member Posts: 5
edited November 2022 in Community Support
Hello, I am doing a prototype with the OnShape API for an internship, which involves showing an assembly in GLTF on another webpage. So far I've been able to work my way through the API except this. When I get the data for an assembly I get a occurrences.transform property that looks like this: 
<div>transform: [</div><div>&nbsp; &nbsp; 1,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; -0.11526866659459908,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 1,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; -0.02565412583836096,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 1,</div><div>&nbsp; &nbsp; 0.01184993247305625,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 0,</div><div>&nbsp; &nbsp; 1</div><div>]</div>
How do I know what these values stand for? I've looked around, but can't seem to find any definition for these. I assume index 3, 7 and 11 are x y and z respectively, but what about the other values.

Edit: Looks like the code block didn't get posted right. So here's a hastebin link: https://hastebin.com/nogivuporo.yaml 

Edit 2: Further investigation leads me to believe that index 2, 6 and 10 represent the rotation, though these numbers don't seem to line up with radians, degrees or gradiens? Is there some catch with this?

Best Answer

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    edited November 2022 Answer ✓
    The transformation matrix is a 4x4 matrix comprised of a rotation matrix, translation array, uniform scale, and i think non-uniform scale(? havent confirmed this, but it doesn't matter in most use cases).

    the indices
    0,1,2
    4,5,6
    8,9,10
    Are the rotation matrix.

    indicies
    12,13,14
    3,7,11
    are the translation array

    index 15 is the scale parameter (default to 1)

    And the indicides
    3,7,11
    12,13,14
    I believe are non-uniform scaling, but I have tested them, these should be set to zero.
    Its possible they aren't supported.

    Peter Brinkhuis has written a great article about transformations specific to the solidworks api here
    A lot of it applies to the onshape transform, but the indicies are in a different order.

Answers

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    edited November 2022 Answer ✓
    The transformation matrix is a 4x4 matrix comprised of a rotation matrix, translation array, uniform scale, and i think non-uniform scale(? havent confirmed this, but it doesn't matter in most use cases).

    the indices
    0,1,2
    4,5,6
    8,9,10
    Are the rotation matrix.

    indicies
    12,13,14
    3,7,11
    are the translation array

    index 15 is the scale parameter (default to 1)

    And the indicides
    3,7,11
    12,13,14
    I believe are non-uniform scaling, but I have tested them, these should be set to zero.
    Its possible they aren't supported.

    Peter Brinkhuis has written a great article about transformations specific to the solidworks api here
    A lot of it applies to the onshape transform, but the indicies are in a different order.
  • kevin_dolfingkevin_dolfing Member Posts: 5
    Thanks for the good resource @caden_armstrong. However I believe that 12,13 and 14 is the non-uniform scaling and 3, 7 and 11 is the translation array. Reason for this is that I haven't seen a single 3, 7, 11 that has been 0 from the api, while 12,13 and 14 always were. Translation matrix really was a keyword I needed. I will have a go at this
  • kevin_dolfingkevin_dolfing Member Posts: 5
    For those who might see this in the future. I was using Three.js as a renderer and tried using the wrong Matrix4 method. I used Matrix4.fromArray, where I should have used Matrix4.set.
  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    @kevin_dolfing Yes you are correct.

    I had it confused with the view matrix, which is transposed from the transform matrix.
  • stephanos_androutsellisstephanos_androutsellis Member Posts: 2

    Thank you! That's exactly what I was looking for… :-)

Sign In or Register to comment.