Finding new rotated 3d coordinate points?
-
I have a defined face which is made up of four 3d points such as:
base = entities.add_face(pt1, pt2, pt3, pt4)
I now rotate that face 45 degrees by:
t = Geom::Transformation.rotation(pt0,Geom::Vector3d.new(0,0,1), 45.degrees) group.move!(t)
The original face has now been rotated about a some point pt0. I can determine using math the new pt1new, pt2new, pt3new, pt4new co-ordinates of that rotated face, but is there a more direct and less tedious method I'm not aware that will allow me to determine those new 3d points?TIA!
-
I think there was a recent topic on this...
lets see, perhaps:
grpdefn = grp.entities.parent pts = [] grpdefn.entities.each {|e| if e.is_a?(Sketchup;;Face) e.vertices.each{|v| pts << v.postion } end } pts.uniq!
-
Also if the face is the only thing in the group, you may use
group.local_bounds
-
Using
group.move!(t)
will miss the 'undo stack' [typically used in animations], whereas using
group.transform!(t)
won't.
You can apply a transformation to a 3d point [and vector] too, to make a new reference use
pt1new=pt1.transform(t)
or
pt1.transform!(t)
to 'reuse'pt1
which is '!' changed to its matching vertex's current value
https://developers.google.com/sketchup/docs/ourdoc/point3d#transform
Advertisement