2
$\begingroup$

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.

http://goput.it/lha.png

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 
  • 0
    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...2012-05-12
  • 0
    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$...2012-05-12

1 Answers 1