Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a first person shooter game, and I've got so far. I'm now trying to develop the code that shoots a bullet.

I know what the co-ordinates of A are (this is where the character is standing), and I'm trying to work out what the co-ordinates of F are (the direction of the bullet is length C, I know what this is too) - to do this I need to find out what the lengths of D and E are. I know what angle B is in degrees.

Can anyone please provide me with a formula that can fill the gaps in (D and E)?

A = Where character is stood (I know the co-ordinates)
B = Angle (I know the angle)
C = Direction of bullet (I know the length)
D = I don't know this
E = I don't know this
F = I need to know D and E to find out what these co-ordinates are
share|cite|improve this question
You know angle $B$, so you know that the slope of the segment of length C is $\tan(90^\circ-B)$. You know $A$'s coordinates, so building the equation of the line joining $A$ and $F$ should be a snap, after which the coordinates of $F$ can be obtained rather easily... – J. M. May 12 '12 at 15:28
Alternatively: if you have the coordinates $(p,q)$ of $A$, then the parametric equations $$\begin{align*}x&=p+t\cos(90^\circ-B)\\y&=q+t\sin(90^\circ-B)\end{align*}$$ ought to be of use, and then consider what happens if you replace $t$ with the length of segment $C$... – J. M. May 12 '12 at 15:30

We know that $$D = C \cos \angle B$$ $$E = C \sin \angle B $$ (You can verify these in any introduction to trigonometry.) I trust you can find the coordinates of $F$ from these.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.