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.

# How do I get relative Position and Orientation between two mates?

javl0p_2
Member Posts:

**23**✭
I'm working inside an Assembly. I have two mates

Mates are basically reference systems, and relative position and orientation between reference systems are typically represented with a

The problem is that a haven't figured out a way in OnShape to get the necessary information to compute relative orientations between mates. I can easily get the translation by selecting both of them and clicking the measure icon and I have found a

Has anyone else encountered this limitation or found a way to sort it out?

I understand this is not a typical design problem, but transformations are used quite often in other industries, such as robotics.

**already**placed, each of thems belongs to a different Part. I would like to know the position and orientation of one mate relative to the other one.Mates are basically reference systems, and relative position and orientation between reference systems are typically represented with a

**4x4 Transformation Matrix**. Other options include a traslation + orientation (which can be defined with**Euler angles**, in**Axis angle**representation or through**quaternions**). Each way of representing relative orientations has its pros and cons but for me they would be equally valid.The problem is that a haven't figured out a way in OnShape to get the necessary information to compute relative orientations between mates. I can easily get the translation by selecting both of them and clicking the measure icon and I have found a

*Multi Mate Connector FS*that could potentially help me, but since I'm inside an Assembly I can not rely on that either.Has anyone else encountered this limitation or found a way to sort it out?

I understand this is not a typical design problem, but transformations are used quite often in other industries, such as robotics.

0

## Answers

1,710PROhttps://forum.onshape.com/discussion/19018/measure-mate-connector-orientation

https://forum.onshape.com/discussion/11293/measure-between-mate-connectors-in-mate-connector-frame

23✭https://forum.onshape.com/discussion/20536

1,944PROA mate connector doesn't map to a transformation, you need 2 transforms.

If you don't use the bottom rotation, then you can get away with 1 matrix transform. I don't think these matrices are part of a mate connector and you'll have to build them. You could just perform the last rotation using trig but I wouldn't. It seems like a waste to construct a matrix to perform a simple rotation, but in the end, linear algebra is just accounting so you want to keep things in the same 4x4 form.

1 MatrixIn cad everything goes through the origin.

M1 is the transformation from the origin to mate connector 1.

M2 is the transformation from the origin to mate connector 2.

So your transformation actually looks like this:M1 -> origin -> M2.

M1 -> to the origin is the inverse matrix of origin -> M1. Onshape calls these "sketch to origin" or "origin to sketch". So the 1st step is to go from the mate connector to the origin which is the inverse of the definition when placing the mate connector.

Using value with units and M1 & M2 are matrices.

M1^-1 * M2 = would equal the matrix you're looking for when not using the bottom rotation in the mate connector dialog.

Figuring out the translation between 2 mate connectors is easy: M2-M1. There's only 2 vectors involved. I doubt if you could subtract the 2 mate connectors, but instead, pull the vectors from the M1 & M2 and perform the math on them.

I don't know if values with units handles matrices, I believe it does and I'm sure how to call a matrix inversion inv(M1)?

2 MatrixM1.1^1*M1.2^*M2.1*M2.2 there's 4 transformations when using 2 mate connectors. If you're at a mate connector and want to get back to the origin, you have to use the inverse matrix.

So with the transformation feature script I'm writing, I create 6 transformations that will go from the origin to a robot's end effector. If you're at the end effector and want to go back to the origin, you just invert all the matrices and go back to the origin. If you want to know where the end effector is located, you just multiply the transformation stack and you'll end up with a matrix that describes the end effectors location & orientation from the origin.

If you want a skeleton of a robot without using a million sketches, you'll want to use a transformation featurescript to define a robot's structure.

I've been trying to justify why we need a transformation featurescript, thanks for posting this.