Re: Help with drawing
Re: Help with drawing
- Subject: Re: Help with drawing
- From: Chris Goedde <email@hidden>
- Date: Sat, 16 May 2009 10:36:01 -0500
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 (email@hidden)
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:
This email sent to email@hidden