Search code examples
vectorcoordinatesangle

Vectors calculation based on speed and angles


I am having a tough time applying vector knowledge to a real situation: I am working on implementing a near collision detection algorithm for ships (not predictor) based on this paper. The data I have is location (x,y), course (angle from north), and speed for each ship (let's say only ship A and B).

Three of the components I need are: relative velocity between the ships, unit vector parallel to ship course, unit vector perpendicular to relative velocity (the overall formulas can be seen in chapter 4). The first formula is given in the paper, while the next 2 I got from a math book:

1) relative velocity V(BA) = C(B) - C(A) (all vectors; within brackets -> subscript)

I'm assuming the C's mean the course (which is an angle). From my understanding, relative velocity is measured in distance over time while a vector has a magnitude (speed?) and orientation (course?).

2) unit vector = vector / magnitude
3) perpendicular vector = any vector <=> dot product = 0

Therefore my question is: how do I use the data I have (i.e. speed, course, location) to calculate these equations?

Regarding vectors, the only thing that comes to mind to calculate a vector is using two points (so 2 x,y pairs), which however seems odd in this case.


Solution

  • Let's say you have position in coordinates x (horizontal, positive when West to East) and y (vertical, positive when South to North), a speed s and a course c (angle in relation to North, clockwise) for each ship.

    You can get the Cartesian components of the velocity, vx and vy, by using:

    vy = scos(c)

    vx = ssin(c)

    And then you can add or subtract the vectors term-wise at will.