sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    MSPhysics tests and questions

    Scheduled Pinned Locked Moved Plugins
    104 Posts 21 Posters 44.7k Views 21 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.
    • robintR Offline
      robint
      last edited by

      Thank you so much Anton, I was just about to post an apology for a stoopid boy Pike moment (no smilie for Duh 😳 )

      but I read the second line and it outputs frame to screen, what a numpty

      You gave me some other scrip that outputs velocity, strange to note that the cube reaches a terminal velocity ca 2m/s ca halfway down - intriguing. Is there something in there that simulates viscosity?

      onUpdate {

      Get current velocity

      cv = this.get_velocity

      Output it in the note

      note = sprintf("Velocity: (%.3f, %.3f, %.3f)", cv.x, cv.y, cv.z)
      simulation.display_note(note)
      }

      Cheers

      Robin

      As one door closes another one slams in your face

      1 Reply Last reply Reply Quote 0
      • A Offline
        Anton_S
        last edited by

        Yes, the viscosity is simulated by the linear damping. To remove the linear damping, select the desired group, open MSPhysics UI, activate the Properties tab, and set Linear Damping to 0.00. This should alter the height of terminal velocity.

        If you meant something else, like water or buoyancy, you can add a buoyancy plane by navigating to (Menu)Extensions->MSPhysics->Create Buoyancy Plane. Although the liquid is not simulated. It's just the buoyancy force that is applied.

        1 Reply Last reply Reply Quote 0
        • robintR Offline
          robint
          last edited by

          Hi Anton

          Just when I thought you cracked it with speed, something strange happens

          When dropping the block from 10m = ok = 14m/s as per calc (see model)

          Move the block down to 5m => nonesense answer like 0.07... (should be 9.9m/s)

          Yet move block to other elevations like 8.5m or 2.5m , seems to work ok (but I haven't checked the result against calcs (12.9, 7)

          So I am completely stumped πŸ˜’

          BTW sometimes the block appears to penetrate the baseplate and slowly return to zero, could this be the reason?

          Thats ruined my day

          Cheers

          Robin


          falling block2.skp

          As one door closes another one slams in your face

          1 Reply Last reply Reply Quote 0
          • robintR Offline
            robint
            last edited by

            Maybe uncovered a nasty bug? Anton

            Here's a suggestion from your speed indicator

            onUpdate {

            Get current velocity

            cv = this.get_velocity

            Output it in the note

            note = sprintf("Velocity: (%.3f)", cv.z)
            simulation.display_note(note)
            }

            When it runs, on collision it displays 0.00 as expected, the block has stopped but we lost the terminal velocity

            Could we say put an IF loop in the output velocity to note, only iff velocity <say .5m/s, then it should go to zero when the block stops (assuming no bounce)

            Just a thought, maybe a simpler approach? from a ruby newby

            Cheers

            Robin

            As one door closes another one slams in your face

            1 Reply Last reply Reply Quote 0
            • robintR Offline
              robint
              last edited by

              Sorry, Im getting tired

              I meant it should retain the highest last value in note when the block stops

              Apologies

              Robin

              As one door closes another one slams in your face

              1 Reply Last reply Reply Quote 0
              • A Offline
                Anton_S
                last edited by

                It's all cool πŸ˜„

                Here is the code for viewing maximum velocity.

                onStart {
                  @max_vz = 0
                }
                
                onUpdate {
                  v = this.get_velocity
                  if v.z.abs > @max_vz
                    @max_vz = v.z.abs
                    simulation.display_note(sprintf("Max Speed %.3f m/s", @max_vz))
                  end
                }
                

                And yes, the speed indicator in onTouch may not always work right, which is the problem of the physics engine that my wrapper is using.

                1 Reply Last reply Reply Quote 0
                • robintR Offline
                  robint
                  last edited by

                  Hi Anton

                  Installed your script, works a treat and pretty accurate 😎

                  However I have meddled and got stuck, I cant find a way to print another result on a new line, tried everything, puts, print (can't find sprintf in docs either)

                  As you see I want to print elapsed time as well and it works but overwrite the Max Speed result on the same line

                  I feel really dumb getting stuck on this trivial matter, pls help 😒

                  BTW would I be right in saying that MSP script is a subset of official Ruby 2.0 and some elements like puts and print (they dont do anything on screen or riase an error)are left out?

                  Cheers

                  Robin


                  falling block3.skp

                  As one door closes another one slams in your face

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Anton_S
                    last edited by

                    Here:

                    onStart {
                      @max_vz = 0
                    }
                    
                    onUpdate {
                      v = this.get_velocity
                      if v.z.abs > @max_vz
                        @max_vz = v.z.abs
                        simulation.display_note(sprintf("Max Speed %.3f m/s\nElapsed Time; %.2f s", @max_vz, world.time))
                      end
                    }
                    
                    1 Reply Last reply Reply Quote 0
                    • robintR Offline
                      robint
                      last edited by

                      Anton, ooh that is nice

                      from little acorns, great oaks grow

                      So now we have a timer as well

                      Maybe add

                      add the x.y.z distance travelled

                      and then I can perhaps simulate a cannon firing a cannon ball at a target

                      and with a bit of wind and air friction, elementary gunnery for the Napoleonic War

                      I will of course present my models to you for the consideration of others in the interest of MSP

                      Cheers, many thanks
                      Robin


                      falling block4.skp

                      As one door closes another one slams in your face

                      1 Reply Last reply Reply Quote 0
                      • robintR Offline
                        robint
                        last edited by

                        Hi Anton

                        Just seen your Turret thingy, blown away by it
                        30 pages of code - I might as well try and become a brain surgeon!

                        Link Preview Image
                        3D Warehouse

                        3D Warehouse is a website of searchable, pre-made 3D models that works seamlessly with SketchUp.

                        favicon

                        (3dwarehouse.sketchup.com)

                        Very skilful

                        Robin

                        As one door closes another one slams in your face

                        1 Reply Last reply Reply Quote 0
                        • gillesG Offline
                          gilles
                          last edited by

                          Just playing with basics,
                          Screw-MSP.gif
                          brought me to some questions:

                          When you at the screws,
                          -one is static mesh and is collision shape fits perfectly.

                          • to achieve the same collision shape for the mobil oneI had to it with several components.

                          Any reason the soft isn't able to calculate the same collision shape but not static?

                          To make those movements running well I used a workaround.

                          For rotation we have hinge, motor, servo.
                          For translation we have slider, piston, why not a linear motor?
                          For translation + rotation we have corkscrew, why not motor + linear motor , servo + piston, servo + linear motor , linear motor + piston?
                          For curve we have curvy slider and curvy piston, why not a curvy motor and curvy piston?

                          Nota bene: just curiosity here, no request.


                          Vis MSPhysic.skp

                          " c'est curieux chez les marins ce besoin de faire des phrases "

                          1 Reply Last reply Reply Quote 0
                          • robintR Offline
                            robint
                            last edited by

                            At last

                            Terminal velocity
                            Time
                            Distance

                            Now the basis of my cannon project

                            Anton has made a sophisticated urret thingy available on 3D warehouse/msphysics

                            but I want to make a simpler model for a gunner with inputs for
                            horiz angle
                            Azimuth
                            muzzle velocity
                            Range (from a range finder measurement of a distant target placed at random)
                            Air density (from Bar pres, RH and temp)
                            Air friction ?

                            output > distance landed from target (eg a forward spotter)

                            Simplistic stuff for a Napoleonic gunnery officer

                            Maybe a moving target next (eg tank)

                            On the 7th day god made Robin


                            falling block6.skp

                            As one door closes another one slams in your face

                            1 Reply Last reply Reply Quote 0
                            • F Offline
                              faust07
                              last edited by

                              Hi Anton, after extensive tests with the fairly complex ice stage model, I can report that everything works very well.
                              I just had to reverse some curves and exchange the programmed Curvy Piston Joint for the Orca. The calculation of the transformed emitter objects seems to work more precisely.
                              This costs a little more time for the simulation, but the viewport problems no longer occur.
                              That's great! Thank you very much!
                              I have extended the simulation around a rain with middle large hailstones and it works.
                              And for the future the integration of the good old SketchyPhysics fracture/split function and a kind of soft or flexible surfaces would be great...
                              πŸ‘


                              NewYear-Test_07.gif


                              frame_000196.jpg

                              1 Reply Last reply Reply Quote 0
                              • A Offline
                                Anton_S
                                last edited by

                                Thanks for testing and verifying, Faust. Next feature would be to improve performance of export to Skindigo and Kerkythea. I think there is a way to reduce export redundancy. The fracture thingy would be implemented too.

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  faust07
                                  last edited by

                                  Sounds good!

                                  1 Reply Last reply Reply Quote 0
                                  • F Offline
                                    faust07
                                    last edited by

                                    Testing MSPhysics in SketchUp 2017.
                                    In a direct comparison between SketchUp Make 2016 and 2017, this incomplete image is created in 2017 when using the following script:

                                    Sketchup.active_model.active_view.write_image("e;/MSPh_Temp/frame_%06d.png" % frame,1600,900,true,1.0)
                                    

                                    How should it be right for SUp 2017?


                                    result in SUp 2016


                                    result in SUp 2017

                                    1 Reply Last reply Reply Quote 0
                                    • Z Offline
                                      ZoltanSpin
                                      last edited by

                                      (learning Ruby for MSphysics)
                                      I would like to move several objects, each one following an (x,y,z) curve, in a synchronous manner.
                                      I imagined to have a public tick and then on tick each body compute its next (x,y,z) position and goes there using set_velocity([vx,vy,vz]).

                                      • is this a correct way to use MSphysics scripts? Are there (close) examples in warehouse?
                                      • how to write if for, say, a cube moving at 1m/s from x=0 to x=100m then when x=100 --> x=0 and loop?
                                        Thank you for your help.
                                      1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        Anton_S
                                        last edited by

                                        Hello, Zoltan,

                                        Yes, you understood the concept correctly.

                                        For such behavior, however, a script might not be necessary. You can use a Piston or a CurvyPiston joint. When you add a Piston joint, set its position units to m, linear rate to like, 1000, and the controller to, world.time % 10. This will generate a value b/w 0 and 10 on a timescale of 10 seconds.

                                        Also, in case you don't know how to use joints, here is a Wiki:
                                        https://github.com/AntonSynytsia/MSPhysics/wiki/Using-Joints

                                        But if you want a special behavior that would teleport a moving object after it surpasses a scalar of a coordinate, then this is how you do it:

                                        onStart {
                                          @max_x = 100.m
                                          @start_pos = this.get_position(1)
                                        }
                                        
                                        onUpdate {
                                          this.set_velocity(1,0,0)
                                          if this.get_position(1).x > @max_x
                                            this.set_position(@start_pos)
                                          end
                                        }
                                        

                                        Paste this script into the desired moving object(s).

                                        Basically, this will move an object at 1 m/s along the x-axis and teleport it back to start when the objects X coordinate surpasses maximum x position.

                                        You can also, instead, control it by force rather than velocity:

                                        onStart {
                                          @max_x = 100.m # in inches; the .m converts it meters to inches.
                                          @start_pos = this.get_position(1)
                                          @des_vel_x = 1 # in m/s
                                        }
                                        
                                        onUpdate {
                                          # Compute the desired acceleration in m/s/s -> (des_vel - cur_vel) / timestep
                                          ax = (@des_vel_x - this.get_velocity.x) / simulation.update_timestep
                                          # Apply force
                                          this.add_force(ax * this.mass, 0, 0)
                                          # Teleport if necessart
                                          if this.get_position(1).x > @max_x
                                            this.set_position(@start_pos)
                                          end
                                        }
                                        

                                        Applying forces are better than applying velocities because they don't dissipate any other forces like the force of gravity or the force of contacts. Also, if you don't want to have the object be affected by the gravity, you can, as well, add force to the z component, like 9.801 * this.mass or you can simply disable gravity for the object. Both yield the same behavior.

                                        But, like I said, to if you want to create moving platform that doesn't involve teleportation, you can add a Piston joint and connect it to the desired object. Then add an oscillator controller to the Piston joint, like oscillator(50)*100.

                                        Regards,
                                        Anton

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          DingBEN
                                          last edited by

                                          I created a floor (static mesh), and a ball and a cube both compounds
                                          I tilted the floor (5)
                                          ...Friction ON

                                          Play:

                                          • Ball rolls to the edge of the floor and stops! ?
                                          • Cube does not even move

                                          ...Friction OFF

                                          • both roll/slide off the floor and disappear in the abyss

                                          I wait for 10 15 secs,

                                          • the floor's front face disappears so the inside of the floor can be seen,
                                          • and from that face the floor melts away until it reaches the back right corner
                                          • then it melts from the back right corner to the left one and vanishes!

                                          Also if using any SketchUp commands, for example, to realign the scene
                                          then the behavior of objects and mouse pointing and other function go to the abyss of absurdity

                                          Hope this is helpful.

                                          1 Reply Last reply Reply Quote 0
                                          • F Offline
                                            faust07
                                            last edited by

                                            Hi DingBEN,
                                            I guess the ball stops at the edge because its shape is defined as "Compound".
                                            You could test is with a collision shape "Sphere".
                                            When in MSPhysics objects fall down into infinity, they gradually enlarge the overall model.
                                            They are falling too far away from the camera.
                                            And the "clipping" problem known in SketchUp is getting stronger until all objects are optically cut off in the field of view of the camera.
                                            You can read a bit more about the "clipping" issue here:
                                            http://support.google.com/sketchup/bin/ ... swer=36261

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

                                            Advertisement