# 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.

## Recommended Posts

hey everyone

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)

thanks for the helpers

Edited by MaorNr

##### Share on other sites

Can you post an image of what you're asking?

##### Share on other sites

Can you 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 .

##### 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 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?

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 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 ?

mistake....

Edited by MaorNr

##### 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 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 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.

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632986
• Total Posts
3009725
• ### Who's Online (See full list)

There are no registered users currently online

×