user3532825
user3532825

Reputation: 3

C Formula help circular positiong

I am trying to calculate the angle at which the a ball spinning in a circle lands on. I have this to make it move around a circle:

    BallPositionX = (cos( degreesToRadiansMultiplier * BallPositionAngle ) * 215) + centerPointX;
    BallPositionY = centerPointY - (sin( degreesToRadiansMultiplier * BallPositionAngle ) * 215);

The 'BallPositionAngle' is calculated by:

    BallPositionAngle += (BallSpeed * multiplier);

Where the 'BallSpeed' is a random number between 1 and 100 and the 'multiplier' is the frame number in the animation. This is repeated every frame until frame number 78 when the ball stops.

I wrote this formula to actually work out its final angle:

Winning = ((2*acos(((BallPositionX-centerPointX)/215)))/degreesToRadiansMultiplier);

The formula keeps giving me an almost random angle every time which is nowhere near the balls actual position.

Can anyone think of an easier way to do this? Or correct anything I have done? I need an angle in degrees for the rest of my code to function.

I am using C and have no idea what compiler my lecturer is making me use.

Upvotes: 0

Views: 45

Answers (1)

Shawn C
Shawn C

Reputation: 356

Pretty sure your BallPositionAngle formula needs to drop the +:

BallPositionAngle = (BallSpeed * multiplier);

Upvotes: 1

Related Questions