Box sliding down multiple ramps

  • Thread starter clamport
  • Start date
1
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
 

fresh_42

Mentor
Insights Author
2018 Award
11,569
8,028
You simply have to set up the equations of motion with a starting velocity, which is a constant additive term.
 

Want to reply to this thread?

"Box sliding down multiple ramps" You must log in or register to reply here.

Related Threads for: Box sliding down multiple ramps

  • Posted
Replies
1
Views
2K
  • Posted
Replies
1
Views
2K
  • Posted
Replies
1
Views
1K
  • Posted
Replies
11
Views
3K
  • Posted
Replies
2
Views
2K
  • Posted
Replies
2
Views
2K
  • Posted
Replies
20
Views
4K
  • Posted
Replies
5
Views
1K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving

Hot Threads

Top