On May 16, 2009, at 2:24 AM, Graham Cox wrote:


On 16/05/2009, at 5:01 PM, Development wrote:

theX = turretBottom.x + 103* sin(angle * PI/180);

Above is what I am using to get the X coord now I need it exactly opposite the point it appears at. 103 is the height of the turret. angle is the angle it is in relation to the platform it sits on. (moves from 0 to 75 degrees)

Any one out there who knows more about math than me who might be able to help me invert this X coord?


X co-ordinates require the cosine of the angle, not sine. so it should be:

Whether sine or cosine is appropriate depends on whether the angle is being measured relative to a vertical or horizontal reference. It sounds to me like the OP is thinking that angle == 0 corresponds to a vertical turret, so sine would be appropriate in that case.

OP, if angle > 0, then your line above will always give a value for theX that is great than turretBottom.x (assuming angle doesn't exceed 180). If you want a value less than turretBottom.x, you could either use

theX = turretBottom.x - 103* sin(angle * PI/180);

with a positive value of angle, or

theX = turretBottom.x + 103* sin(angle * PI/180);

with a negative value for angle. The function sine is odd, so mathematically sin(-x) = -sin(x).

Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to