To find a point relative to a point at a distance at angle .

Leave a reply

To find a point relative to a point at a distance at angle .

To find the offset on a vector perpendicular to a point use the dot product

Assume the vector is defined by P1 and P2 and the point by P

in 2d

(P.x - P1.x) * (P2.x - P1.x) + (P.y - P1.y) * (P2.y - P1.y) offset = ----------------------------------------------------------------- (P2.x - P1.x) * (P2.x - P1.x) + (P2.y - P1.y) * (P2.y - P1.y)

or 3d

(P.x - P1.x) * (P2.x - P1.x) + (P.y - P1.y) * (P2.y - P1.y) + (P.z - P1.z) * (P2.z- P1.z) offset = --------------------------------------------------------------------------------------------------- (P2.x - P1.x) * (P2.x - P1.x) + (P2.y - P1.y) * (P2.y - P1.y) + (P2.z - P1.z) * (P2.z - P1.z)

**notes:**

If vector P1,P2 has been normalized (length 1) the division by the length is obviously not necessary. If not the result is divided the square length. Although divided by the length (square root) the result will equal that of a normalized vector. Keep in mind that the dot project is a projection on the vector thus requiring a additional division by the length!

Calculating the point on the vector can be done using

P.x = P1.x + (P2.x - P1.x) * o; P.y = P1.y + (P2.y - P1.y) * o; P.z = P1.z + (P2.z - P1.z) * o; (3d)