Artificial intelligent assistant

Angle of a javelin at any given moment I am using the following formula to draw the trajectory of a javelin (this is very basic, I am not taking into consideration the drag, etc.). speedX = Math.Cos(InitialAngle) * InitialSpeed; speedY = Math.Sin(InitialAngle) * InitialSpeed; javelin.X = speedX * timeT; javelin.Y = speedY * timeT - 0.5 * g * Math.Pow(timeT, 2); How do I know at what angle my javelin for a given timeT?

The velocity of the javelin is the first derivative of the position:


javelin.vx = speedX;
javelin.vy = speedY - g * timeT


Assuming a well-thrown javelin always points in the direction of travel, the angle can be found using the arctangent function:


javelin.angle = atan(javelin.vy / javelin.vx);


If you are writing code, you can prevent a division by zero by using a version of arctangent that takes the rise and run as separate parameters:


javelin.angle = atan2(javelin.vy, javelin.vx);

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ca0077463d7ec4a03f0fbfda36ade711