• Create Account

### #ActualCruis.In

Posted 03 January 2013 - 12:15 PM

disregard

### #1Cruis.In

Posted 03 January 2013 - 11:18 AM

I am 85% there. Just need clarifications.

vector theory says that the dot product of two vectors is equal to the magnitudeof each multiplied together, all multiplied by the cosine of the angle between them.

the magnitude of a vector is the vector added like: vx * vx + tx * ty

so the magnitude of my ships vector = shipX * shipX + shipY * shipY

enemy ship                                        = eshipX * eshipX + eshipy * eshipy

(vector1 * vector2) where 1 = my ships vector and 2 = enemyship vector

now to find the angle between those two vectors can we use atan2?

pseudo code

new arc = atan2(vector2, vector1)

then find the cos of new arc... arc2 = cos(newarc) 'your finding the cos of the angle between vector 1 and vector 2

then multiply the magnitude by the cos of the angle between the vectors

somehow that all seems wrong

****************

angle = atan2(eshipY - shipy, eshipx - shipx) 'this should be the angle between my ship and the enemy between our two vectors

angle2 = cos(angle) ' this is now the cos of the angle between the two vectors

dot product =  (vector1 * vector2 ) * arc2

nope that don't work either.

***************************

The vector from you to an enemy is posEnemy - posYou so if you are at (10, 0) and an enemy is at (5, 5) then the vector towards them is (5-10, 5-0) = (-5, 5), normalised (-1/sqrt(2), 1/sqrt(2)).

i think this part stumps me.

PARTNERS