Jump to content
  • Advertisement
Sign in to follow this  
HopHopTraLaLaGdaltiBshAna

Ball moving by slope

This topic is 1474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey everyone smile.png

 

there are circles which move by line like ax+c , but there is a little problem :

 

as the slope are bigger the ball move faster , how can I solve this ?

 

I want only the direction of the line, I thought about that the circle will move by 1x+c , and then I will rotate him by tanf(a) smile.png

 

thanks for the helpers smile.png

Edited by MaorNr

Share this post


Link to post
Share on other sites
Advertisement

 


ou post an image of what you're asking?

I have line (ax+c) which the ball step on , but when the slope are higher the ball move faster ..

 

I want the ball move only by the direction .

 

 

So, the ball's horizontal movement was based on x/t, and you want the ball to move at a constant rate, regardless of the slope?

 

Just use the slope angle (based on a, if you're talking mx+b line equation), and do some basic trig to scale the velocity of the ball.

 

Multiply the velocity by the Cos of the slope angle.  

 

Or are you asking how to get the slope angle from your a? 

 

Tan of your angle = m (a in your case)

 

So... arctan (a) = angle.

 

Cos (arctan(a)) ... I had to look that one up:

 

 1 / sqrt(1 + a^2)

 

I guess multiply your velocity by that (if I understand your question correctly, and I didn't screw up the math somewhere).

Edited by StarMire

Share this post


Link to post
Share on other sites

 

 


ou post an image of what you're asking?

I have line (ax+c) which the ball step on , but when the slope are higher the ball move faster ..

 

I want the ball move only by the direction .

 

 

So, the ball's horizontal movement was based on x/t, and you want the ball to move at a constant rate, regardless of the slope?

 

Just use the slope (based on a, if you're talking mx+b line equation), and do some basic trig to scale the velocity of the ball.

 

Multiply the velocity by the Cos of the slope angle.  

 

Or are you asking how to get the slope from a? 

 

 

thanks !!!!!!!!!!!!!!!!!!!

 

                x += ((power * cos(atan(balline.a))) * -Vector);
                y = balline(x);

its works !!!

 

can you explain me why is this happen ?

Share this post


Link to post
Share on other sites

No problem, glad you got it working.  I wasn't 100% sure what you were asking, but I took a guess.

 

can you explain me why is this happen ?

 

Your ball's movement was constant with regards to X.  It was still constant with regards to X now that your slope changed, but it was a much longer line (because it was also moving with regards to Y), so the total magnitude of the velocity was higher.

 

You had to scale down the velocity such that the full magnitude would remain the same (X + Y), which meant multiplying it by your original velocity divided by the new magnitude.

 

Cosine is:  CAH  (remember SOH CAH TOA).  That is, Adjacent over Hypotenuse.  Your new magnitude is based on the Hypotenuse.  Adjacent is your horizontal, the original magnitude with regards to X.  So, you wanted Cos of your slope angle.

 

Does that make sense?  Sorry if it's a little hard to explain.

Edited by StarMire

Share this post


Link to post
Share on other sites

No problem, glad you got it working.  I wasn't 100% sure what you were asking, but I took a guess.

 

can you explain me why is this happen ?

 

Your ball's movement was constant with regards to X.  It was still constant with regards to X now that your slope changed, but it was a much longer line (because it was also moving with regards to Y), so the total magnitude of the velocity was higher.

 

You had to scale down the velocity such that the full magnitude would remain the same (X + Y), which meant multiplying it by your original velocity divided by the new magnitude.

 

Cosine is:  CAH  (remember SOH CAH TOA).  That is, Adjacent over Hypotenuse.  Your new magnitude is based on the Hypotenuse.  Adjacent is your horizontal, the original magnitude with regards to X.  So, you wanted Cos of your slope angle.

 

Does that make sense?  Sorry if it's a little hard to explain.

 

is this the same idea as tan(slope angle),  right ?

Edited by MaorNr

Share this post


Link to post
Share on other sites

is this the same idea as tan(slope angle),  right ?

 

Tangent of the slope angle just gives you the Y component of your velocity.  I mentioned that because I wasn't sure if you had access to the slope angle of the line, or if you just had the line's equation.

Cosine lets you scale the magnitude you are using based on the ratio of X and Y together to the original velocity you assigned, because Cosine of the angle = your original velocity / hypotenuse (the new magnitude).

 

Sorry, it's really hard to explain.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!