Box sliding down multiple ramps

  • Context: Undergrad 
  • Thread starter Thread starter clamport
  • Start date Start date
  • Tags Tags
    Box Multiple Sliding
Click For Summary
SUMMARY

The discussion focuses on simulating a box sliding down multiple ramps using physics calculations in a game development context. The user, Chris, successfully implements the sliding mechanics for the first ramp but struggles to transition the box's velocity to subsequent ramps. Key code components include the calculation of net force, velocity updates using Euler integration, and handling of gravitational forces. The solution involves setting up equations of motion that incorporate the initial velocity from the previous ramp as a constant additive term.

PREREQUISITES
  • Understanding of basic physics concepts such as gravitational force and friction.
  • Familiarity with C# programming and game development frameworks.
  • Knowledge of Euler integration for numerical simulations.
  • Experience with vector mathematics, particularly in 3D space.
NEXT STEPS
  • Implement and test the equations of motion for transitioning between ramps in Unity or a similar game engine.
  • Explore advanced physics engines like NVIDIA PhysX for more realistic simulations.
  • Learn about collision detection and response to manage interactions between the box and ramps.
  • Study the effects of different friction coefficients on sliding dynamics in simulations.
USEFUL FOR

Game developers, physics simulation enthusiasts, and anyone interested in implementing realistic motion dynamics in interactive environments.

clamport
Messages
1
Reaction score
0
Hey all,
I was wondering about a box that is sliding down what is basically a half pipe. There are 3 ramps, and I can get the correct sliding on the first ramp, but I can't figure out how to make it move to the next ramp. I am posting my physics code if anyone is interested...
Code:
        public override void Update(GameTime gameTime)
        {
            Console.WriteLine("-- In Physics.Update() Theta is " + theta);
            double Fnet_Magnitude = Net_Force();
            Vector3 Fnet = new Vector3();

            if (theta > 0)
            {// Downhill left side
                Console.WriteLine("Theta is greater than zero");
                Fnet.X = (float)(-Fnet_Magnitude * Math.Cos(           theta   ) );
                Fnet.Y = (float)(-Fnet_Magnitude * Math.Sin( Math.Abs( theta ) ) );
            }
            else if (theta < 0)
            {// Uphill right 
                Console.WriteLine("Theta is less than zero");
                Fnet.X = (float)( Fnet_Magnitude * Math.Cos(           theta   ) );
                Fnet.Y = (float)(-Fnet_Magnitude * Math.Sin( Math.Abs( theta ) ) );
            }
            else
            {
                Console.WriteLine("-In else statement");
            }
            Euler_Update(Fnet);
            

            // So... notes
            // Next X
            // X(i+1) = X(i) + delta(t)*Vx
            //
            // Next Y
            // Y(i+1) = Y(i) + delta(t)*Vy
            //
            // Vx(i+1) = Vx(i+1) + delta(t)(Fx/m)
            //
            // Vy(i+1) = Vy(i+1) + delta(t)(Fy/m)

            base.Update(gameTime);
        }

        private void Euler_Update( Vector3 Fnet_Force )
        {
            //previous_position = position;
            //previous_velocity = velocity;

            position = position + timestep * velocity;
            velocity = velocity + timestep * ( Fnet_Force / (float)mass );
        }

        private bool Sliding()
        {
            //return (__mu_static > __mu_dynamic);
            return true;
        }

        // Ft is tangential force
        // Fn is normal force
        // Fg is gravitational force
        private double Net_Force()
        {
            double Fn = mass * gravity * Math.Cos(           theta   );
            double Ft = mass * gravity * Math.Sin( Math.Abs( theta ) );

            //double mu = (Sliding()) ? mu_dynamic : mu_static;
            double mu = mu_dynamic;

            return Ft - mu * Fn;
        }

Now, for some reason when I update theta the box continues to slide down the previous ramp. So my question is, how do I take that previous velocity and apply it to the new ramp?

Sorry about my confusing topic, I am not a very good math guy...
Thanks!
Chris
 
Mathematics news on Phys.org
You simply have to set up the equations of motion with a starting velocity, which is a constant additive term.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 5 ·
Replies
5
Views
42K
Replies
3
Views
3K
Replies
18
Views
3K