Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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_dolfing
Member Posts: 5 ✭
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> 1,</div><div> 0,</div><div> 0,</div><div> -0.11526866659459908,</div><div> 0,</div><div> 1,</div><div> 0,</div><div> -0.02565412583836096,</div><div> 0,</div><div> 0,</div><div> 1,</div><div> 0.01184993247305625,</div><div> 0,</div><div> 0,</div><div> 0,</div><div> 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?
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?
0
Best Answer
-
caden_armstrong2
Member, User Group Leader Posts: 121 ✭✭✭
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.1
Answers
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.
I had it confused with the view matrix, which is transposed from the transform matrix.
Thank you! That's exactly what I was looking for… :-)
Yeah, you’re basically looking at a 4×4 transformation matrix in row-major order — it’s the standard format used for 3D transforms (translation + rotation + scale).
So the array breaks down like this:
The first 3×3 chunk (
r11–r33) is your rotation (and possibly scale if any). The last column (tx, ty, tz) is your translation in meters.If you’re sending this to a GLTF scene, you can just treat it as a standard transform matrix — most 3D engines (like three.js) have a
Matrix4.fromArray()or similar that’ll accept it directly. No need to convert angles; the rotation part is already baked into the matrix, not in degrees/radians form.