# Mathematics calculation with "Transform" data

Is it possible to perform math operations with transform data? For instance, if I have a rotation transform data and I want to divide it by 2 is there a simple way to do it? I know if I deconstruct the Transform matrix divide some parameters by 2 and then bundle them back together it’s probably possible but requires a lot of fiddling.

Transform.gh (5.5 KB)

You can use deconstruct matrix

@anon39580149 Thank you for your reply, but the rotation angle stays the same, that operation just reduce the length of both X and Y vectors by 2

Yes you are right , Check this

Transform.gh (11.0 KB)

1 Like

@anon39580149 Hmm, the smart trigonometry solution, really thanks. But I suppose there will be much more fiddling if there is a 3D revolution instead of simple 2D. Anyway I get the idea, I will try to write a more universal solution for 3D revolve data as well

Transform.gh (11.8 KB)

Matrices are sometimes invertible and you could play with that… Most of the time though, transformation matrices are a sum of transformations, specially in 3d. Keep in mind that the order of e.g. rotations is crucial. In this case, “half a transformation” is a bit difficult to define.

The solution for 3d rotation is possible by finding (yaw, pitch, roll)
But the problem that python can’t recognize your internalized transform as rotation so we can’t use GetYawPitchRoll.

transform_angles.gh (20.0 KB)

1 Like

@benedict So, it’s often convenient to use relative Transform data during modeling to avoid creating every time spaghetti monster from common components

@anon39580149 Great thanks for your cool work! I didn’t know about “GetYawPitchRoll” function

Check this book of @rajaa , Page 38: Transformation operations

transform_angles.gh (20.9 KB)

2 Likes

@anon39580149 Thank you! Highly appreciate

One thing to watch out for with this-

Converting a rotation to yaw/pitch/roll, then performing a rotation by a multiple of these angles does not in general give you a multiple of the original rotation. It will get to the same result when multiplying by 1, but along the way can follow some strange curves.

Any compound of rotations can be seen as a rotation around a single axis. To get this from a transformation in RhinoCommon you can convert to Quaternion, and from this get the Axis and Angle. Then you can multiply the angle and get exactly what you would if multiplying the angle of the original rotation.

rotation_interpolate_compare.gh (13.5 KB)

2 Likes

@DanielPiker Thank you, Daniel.

hi, do u know how to convert transform matrix to:
xyz cordinates
xyz scale
xyz roatation (based on world plane).

is it even posible?

A 4*4 Trans Matrix tells you the following:

2 Likes

whats bottom right