• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

How to use Geom::Transformation.rotation?

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 4 Posters 1.2k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    wpd
    last edited by 8 Jun 2009, 13:27

    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

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 8 Jun 2009, 13:47

      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.)

      Hi

      1 Reply Last reply Reply Quote 0
      • W Offline
        wpd
        last edited by 8 Jun 2009, 18:12

        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

        1 Reply Last reply Reply Quote 0
        • D Offline
          daiku
          last edited by 8 Jun 2009, 18:17

          @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

          Clark Bremer
          http://www.northernlightstimberframing.com

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 8 Jun 2009, 20:00

            @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.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              1/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement