Grasshopper

algorithmic modeling for Rhino


Is there anything in Grasshopper or the Rhino sdk that can find the single rotation that transforms one orientation to another ?

(I know about the XForm Orient component, but that doesn't allow you to find scalar multiples of the transformation, eg for interpolating an object between two chosen reference planes, or applying the same transform multiple times)

I eventually solved it in Grasshopper with a rather elaborate geometric construction, but was wondering about an easier and more compact way through scripting. Are there any built in methods for getting rotation matrices or Euler angles, or would I have to start from scratch ?

Views: 5784

Replies to This Discussion

Hello, I'm not sure that this will respond to your requiremente of optimization but...let's see.

Well, I created six points (you can create the number you prefer) in order to define the position of my objects. I created 3 traditional planes for each point and then rotated of a given angle. Then I used vetor sum in order to find out the orientation vectors. Then I generated a vertical plane based on that vectors, useful for XForm_Affine_Orient Direction.
Maybe it's not your solution, but I hope will be useful for your further developments!
Bye. Matteo

P.S. This is the result...
Thanks Matteo,

I can't make out your definition from the resolution of that screenshot, do you think you could post it bigger ?
The full sized image is actually stored in the site, it was just re-sized:

I'm sorry Daniel: I supposed it was just a thumbnail of the full-size image and not an image itself.
Here's the definition, so you can see it at every scale you prefer.
Bye.

Mat
Attachments:
Many thanks, but I'm afraid that's not what I'm looking for at all :(

Simply interpolating the components of a 3D rotation and combining them does not result in a single smooth rotation, but an odd curving, twisting motion (because 3D rotations don't commute).
If you do this and trace the movement of the axes you'll see what I mean:


It is a surprisingly deep problem considering how simple it appears at first, but it is well studied and there are lots of different approaches(see http://en.wikipedia.org/wiki/Rotation_representation_(mathematics))

I was about to script something, but wanted to check whether there was already some built-in way to do this before I got started.
Hi. Don't know if I can help here but, here are my comments.

Finding the angle of rotation between two congruent position of solids, objects or just refplanes is possible when we can ensure that the two positions are related by 3d rotation operation, which is not always the case.
If we want to find the transformation that maps one position of an object into another, that transformation will always be a helical transformation - defined by an axis, a translation along that axis and a rotation around the same axis - Seems clear that the case exposed here, the rotation, is a degenerated or reduced situation of this general one.

Anyway, I attached a simple ghx that takes two reference planes - here defined by two sets of three points, and calculates the rotation axis by joining two pairs of corresponding points and calculating the midplanes of the connecting lines. The axis is simply the intersection line between the two planes. Angle then is directly calculated.

Keep in mind that this definition is only valid when the xform applied is a real-pure 3d rotation. Otherwise its a bit more complicated but all the necessary information can be found on the wonderful book by H. Pottman and Others "Architectural Geometry", which I don't have here with me.

I will work on the more general one.
Attachments:
Many thanks Roberto,

That is a very elegant method. I was not familiar with this way of finding a screw transformation before and I like it a lot.

As I said in my first post - I was looking for the rotation that transforms one orientation to another. I realise general transformations have a translation component as well - and in the image I showed the intended use - finding scalar multiples of this combined translation and rotation. Your definition already works great for this.
Still, a method for finding more general screw transformations would be nice to see!

As I mentioned, I already made one geometric gh solution (using half-angle spherical arcs as described here), but I do think your way is neater (in fact, thinking about it now I see that it is an equivalent, but much clearer form of the same method). I'll still look at a scripting solution, because I'd like to be able to do this in a single component, but this is really good to have.

and David - The complex number components are great - quaternions next ? ;)
Hi Again.
Attached you might find a definition that reconstructs the helical movement between two positions of the same Brep. It calculates the angle, the axis and the displacement vector.
Adapting this for any type of geometry must be easy. Just find three pairs of related points.

As I said in my previous reply, helical movement maps any two congruent objects in space.
The definition is based on the method depicted in "Architecturel Geometry" by H. Pottman & Others, from Bentley Institute Press, but I suppose it will be easy to find it in other locations.
Essentially, a Helical transformation can be understood as a rotation around an axis and a translation along the same axis. The clue then, is splitting the Xform in pure translation + pure rotation.


This definition is not degenerated-cases-proof, meaning that a pure translation situation will make GH fail because the plugin wont be able to find the intersection of two planes since all vectors are paralell.
Won't get much into detail but approaching the whole problem via scripting will make special cases managment much easier.

For the helix calculation, since I counldn't find an Helix component in GH, just created it as an interpolated curve on surface, being the surface the extrusion of the rotation arc along the translation vector. The helix is only used for visualization purposes.

I also included some position sampling between initial and final states, which in my opinion makes it look nicer...

Hope this helps you!
Share your results!
Attachments:
That's cool.

I've posted my original method too, in case anyone is interested.

First it extracts the 3 Tait-Bryan angles, then it composes them using Rodrigues' half-angle method.
Attachments:
I don't have much time, and I haven't thought of everything, but it may be helpful. Find the plane for each of the two orientations. Get the intersection line between the two planes. Retrieve the same point from each of the two orientations (referred to now as basepoints). Sample points on the curve until you find a point that is the same distance from each of the basepoints*. This will be your center point. Create vectors from the center point to the two base points and find the angle between those vectors (http://en.wiki.mcneel.com/default.aspx/McNeel/SdkAngle). The last thing that I haven't figured out is how to find the actual axis for the orientation. I can tell you that its not an average of the normals of the orientation planes, but beyond that I don't know. Maybe the article (which I didn't really get a chance to read) or some previous implementations can help find where that axis might be.

*I'm not sure what would be the best way to go about sampling the curve

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service