Math-Rotate Vector

From Vectorlab
Jump to: navigation, search


Adds a rotation to a vector. Sets a variable with the new vector and returns the new angle between the two vectors. It's like applying a further rotation to a rotated line on drawing. By Orso B. Schmid


{ Orso ***************************** }
{ rotates the direction between two points, use 90 for counterclock }
{ returns the rotation of the new segment }
FUNCTION M_RotateVec(startV : VECTOR; VAR endV: VECTOR; rot: REAL): REAL;
	BEGIN
		endV := startV + (Ang2Vec(Vec2Ang(endV - startV) + rot, 1) * norm(endV - startV));
		M_RotateVec := Vec2Ang(endV - startV);
	END;