How to retrive the rotation
-
Hello,
i would like to retrieve the angle of the rotation of the transformation of the entity .
But i cannot find the appropriate metod to do this.
Maybe somebody knows some procedure to do this. -
Ok,if nobody knows it ,i will tell you:
The first 3 elements of the array that you get with transformation.to_a .
The number that comes out is the cos of the angle.Interesting?
3d.new 10,20,30
t = Geom::Transformation.new point
a = t.to_a
UI.messagebox a [0] -
### trans=trans.to_a scalex=Math.sqrt(trans[0]**2+trans[1]**2+trans[2]**2) scaley=Math.sqrt(trans[4]**2+trans[5]**2+trans[6]**2) scalez=Math.sqrt(trans[8]**2+trans[9]**2+trans[10]**2) scale=scalex scale=scaley if scaley>scale scale=scalez if scalez>scale puts " <pos>#{trans[12]} #{trans[13]} #{trans[14]}</pos>\n" puts " <scale>#{scale}</scale>\n" puts " <rotation>\n" puts " <matrix>\n" puts " #{trans[0]/scalex} #{trans[4]/scaley} #{trans[8]/scalez} #{trans[1]/scalex} #{trans[5]/scaley} #{trans[9]/scalez} #{trans[2]/scalex} #{trans[6]/scaley} #{trans[10]/scalez}\n" puts " </matrix>\n" puts " </rotation>\n" ###
Not mine... not sure who came up with it...
-
Wow,this is new for me that there are other classes (like Math) than that from SketchUp Ruby API documentation.
Does anyone have a list and documentation of all included classes in SketchUp Ruby?
Is it possible to include other classes and libraries and how? -
Hi Voljanko, SU has a basic ruby installation that comes with it. I think it was 1.8 or something. But it is missing a lot of things. I don't know if anyone has a complete (or partial) list of exactly what has been excluded.
But you can include ruby files from a regular Ruby installation in your plugins. You just need to figure out what files you need, then include them with your plugin and require them in your plugins. Then you can use the methods and classes they provide.
Chris
Advertisement