How to use Geom::Transformation.rotation?
-
Hello,
I would like to rotate a face about an axis. I have written the following code:group = entities.add_group slice = group.entities.add_face([23.57, -100, Height + 100], [23.57, Width+100, Height+100], [23.57, Width+100, -100], [23.57, -11, -100]) xform = Geom;;Transformation.rotation(Geom;;Point3d.new([23.57, 0, 0]), Geom;;Vector3d.new([0, 1, 0]), 45/360*2*Math;;PI) puts "#{xform.to_a.join(' ')}" group.transform! xform
The problem is that the face does not change orientation. That's not too surprising, given the output of the 'puts()' call (four 1.0 values interspersed with 12 0.0 values -- not too sure exactly what the 16 element array representing a transform really is, but those values do not look much alike a 45 degree rotation).
Is there any better documentation for the Geom::Transformation.rotation API function than:
"The rotation method is used to create a Transformation that does rotation about an axis.
The axis is defined by a point and a vector. The angle is given in radians."Basically, I want to automate the work done by the "rotate" tool in the GUI.
Thanks for any help or pointers.
--wpd
-
I would try 45.degrees instead.
You could also use: 45.0/3602Math::PI
If you divide 2 integers, you get an integer result: 3 / 2 = 1
So 45 / 360 = 0 gets evaluated first (all operators have the same precedence.)
-
Oops... that's embarrassing, especially given how much time I spent trying to understand the meaning of the "point" and "vector" arguments. I'm used to the C convention of promoting everything to the highest level of precision prior to performing arithmetic. So I thought that 45/3602PI would promote to floating point prior to doing any of the math. (Actually, I never "thought" anything with regard to that.)
Thanks for your help.
Is there any mechanism for feeding back additions and clarifications to the Sketchup documentation? I'd be glad to write something about the meaning of the point and vector arguments and about rotating using the right hand rule. Even a simple example of rotating a line or a face (one that had been written using 45.degrees) would have gone a long way to getting me where I wanted to go much sooner.
--wpd
-
@unknownuser said:
Is there any mechanism for feeding back additions and clarifications to the Sketchup documentation? I'd be glad to write something about the meaning of the point and vector arguments and about rotating using the right hand rule. Even a simple example of rotating a line or a face (one that had been written using 45.degrees) would have gone a long way to getting me where I wanted to go much sooner.
Yes - tack it onto the end of this thread:
http://forums.sketchucation.com/viewtopic.php?f=180&t=17047 -
@wpd said:
Is there any mechanism for feeding back additions and clarifications to the Sketchup documentation? I'd be glad to write something about the meaning of the point and vector arguments and about rotating using the right hand rule. Even a simple example of rotating a line or a face (one that had been written using 45.degrees) would have gone a long way to getting me where I wanted to go much sooner.
I second this. Transformations sounded greek to me. Still does. "Translation" does a move..? I'd never have guessed that.
Advertisement