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

    Rotating Spherical components around a common axis

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    8 Posts 3 Posters 2.5k Views 3 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
      wozabee
      last edited by

      Hi guys,
      Here's the mysterious "moving spherical shells" doohickey I've been working on.
      Here's the Sketchup file of the thing in question
      What started as a fun school project with daughter has somewhat snowballed after I theorized that doing the Sun THIS way in Sketchup might be possible. Presently I've just got it to a stage where the 2 "cloud" eyebrows, cheeks, eyes (just both pupils on the same shell underneath), and upper & lower lips, are all made into components, each with all their axis commoned to a point in the back (marked by the arrow tip).
      Sun_Face_02a.jpg

      I still feel that ideal solution to move these bits around would be to modify the "Key rotate" plug-in, as it does most of precisely what I wanted, and can be modified to do 1 degree steps. So far though, after 2 weeks of beginners level Ruby study, and poking about inside Key Rotate, I'm still none the wiser as to exactly how to change what to get it to rotate the components around anything other than the physical centers of the bits themselves.
      Sun_Face_02.jpg

      Presently I just need to "pose" the face and its bits in lots & lots of positions/expressions. But ultimately I''d love to use it as a fun key-frame animation learning/exercise.

      Thanks once again everybody.

      Oh, and here's the previous thread:
      http://forums.sketchucation.com/viewtopic.php?f=15&t=37372

      1 Reply Last reply Reply Quote 0
      • K Offline
        kyyu
        last edited by

        Nice model! I want to learn more on the modeling front myself. I made a few changes to the "key rotate" plugin and I think it now does what you want. I didn't change much, if you look at the code. I commented out the few lines I changed, so you can see what I changed.

        You need to remove the current "key rotate" plugin or they will conflict. Changing the file extention to .txt will do, if you don't want to delete it.

        ky_Key Rotate_modified for sun animation.rb

        -Kwok

        1 Reply Last reply Reply Quote 0
        • W Offline
          wozabee
          last edited by

          WOW, WOW ... and tripple WOW!

          Thank you sooooo much Kwok!!!

          It works a TREAT!!!

          What took me ages before I can now just clickety-click 1 degree at a time to reposition the parts anywhere. It just struck me that this might be perfect for anyone wanting to perhaps play "Gondwanaland" by "jigsaw-ing" all the continents on an Earth globe. maybe operating multi-part hemispherical "Airlock" doors on a starship... The mind boggles.

          I'm still wading through trying your mods to see what you changed to do the magic. Do the pieces rotate on the origin now or the component centers?

          The only thing now is the way using the home/end keys appear to rotate the parts in the z true axis. If you'll notice they "dig in" to the surface as you rotate them.

          I wonder, is there a way to get that function still rotating about the component's volume, but centered toward the same axis as the others? Or would that be an extremely complicated thing to do? Somehow, it seems like that might make this modification to your plug-in truly universal for spherical surface work.

          At any rate, thanks so much for your help.

          Woz

          %(#BFFFFF)[I made a few changes to the "key rotate" plugin and I think it now does what you want. I didn't change much, if you look at the code. I commented out the few lines I changed, so you can see what I changed.

          You need to remove the current "key rotate" plugin or they will conflict. Changing the file extention to .txt will do, if you don't want to delete it.

          [attachment=0:1xpkh394]<!-- ia0 -->ky_Key Rotate_modified for sun animation.rb<!-- ia0 -->[/attachment:1xpkh394]

          -Kwok[/quote]]

          1 Reply Last reply Reply Quote 0
          • K Offline
            kyyu
            last edited by

            Woz,

            @unknownuser said:

            I'm still wading through trying your mods to see what you changed to do the magic. Do the pieces rotate on the origin now or the component centers?

            The x and y now rotate about the origin point. The z still rotates about the component's center point. Remember, the are two key parameters. The point of rotation and the axis of rotation.

            Other than changing the 90 degrees to 1 degrees, I only changed 4 other lines. They are the ones commented out:

            def rotate_X(angle)
            	@sel.each do |e|  
            		 # pt = e.bounds.center
            		 pt = [0,0,0]
            					v = Geom;;Vector3d.new(1,0,0)
            		 tr = Geom;;Transformation.rotation(pt,v,angle.degrees)
            		 Sketchup.active_model.active_entities.transform_entities(tr,e)
            	end
            end
            
            def rotate_Y(angle)
            	@sel.each do |e|  
            		 # pt = e.bounds.center
            		 pt = [0,0,0]
            					# v = Geom;;Vector3d.new(0,1,0)
            					v = Geom;;Vector3d.new(0,0,1)
            		 tr = Geom;;Transformation.rotation(pt,v,angle.degrees)
            		 Sketchup.active_model.active_entities.transform_entities(tr,e)
            	end
            end
            
            def rotate_Z(angle)
            	@sel.each do |e|  
            		 pt = e.bounds.center
            					# v = Geom;;Vector3d.new(0,0,1)
            					v = Geom;;Vector3d.new(0,-1,0)
            		 tr = Geom;;Transformation.rotation(pt,v,angle.degrees)
            		 Sketchup.active_model.active_entities.transform_entities(tr,e)
            	end
            end
            

            @unknownuser said:

            The only thing now is the way using the home/end keys appear to rotate the parts in the z true axis. If you'll notice they "dig in" to the surface as you rotate them.

            Easy enough to fix. I changed the local Z rotation vector from the y axis to a vector pointing to the center of the component. This vector is basically the same as the rotation point (component's center), since the start point is on the origin [0,0,0]. Basically, it's now rotating about the radius of the sphere. I just changed 1 line:

            def rotate_Z(angle)
            	@sel.each do |e|  
            		 pt = e.bounds.center
            					# v = Geom;;Vector3d.new(0,0,1)
            					# v = Geom;;Vector3d.new(0,-1,0)
            					v = Geom;;Vector3d.new(pt.x, pt.y, pt.z)
            		 tr = Geom;;Transformation.rotation(pt,v,angle.degrees)
            		 Sketchup.active_model.active_entities.transform_entities(tr,e)
            	end
            end
            

            Here is the new version:
            ky_Key Rotate_modified for sun animation_02.rb

            -Kwok

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim57
              last edited by

              Beautiful!

              But I gotta ask— what's the light source for the shadows?

              ;—)

              Jim

              1 Reply Last reply Reply Quote 0
              • W Offline
                wozabee
                last edited by

                It's... it's....
                "gahhd. I'm a doctor, not a scientist Jim!"

                @jim57 said:

                Beautiful!

                But I gotta ask— what's the light source for the shadows?

                ;—)

                Jim

                1 Reply Last reply Reply Quote 0
                • W Offline
                  wozabee
                  last edited by

                  It works just absolutely spot-on now!!

                  ...now to re-learn some Keyframe animation & such, and see if I can put this chap through his paces.

                  Thanks so much again Kwok!

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kyyu
                    last edited by

                    @wozabee said:

                    It works just absolutely spot-on now!!

                    ...now to re-learn some Keyframe animation & such, and see if I can put this chap through his paces.

                    Thanks so much again Kwok!

                    Woz, you're welcome. Would love to see the animation, when you are done. ☀

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

                    Advertisement