Math-Add distance to vector keeping the angle

From Vectorlab
Jump to: navigation, search


Given two vectors (like for building a line), adds a distance while keeping the angle. Returns the resulting vector. By Orso B. Schmid


{ Orso ***************************** }
{ adds a distance to a start point of a line keeping the angle }
FUNCTION M_AddDist2Vec(startV, endV : VECTOR; dist: REAL): VECTOR;
	BEGIN
		{ M_AddDist2Vec := startV + (Ang2Vec(Vec2Ang(endV - startV), 1) * (Norm(endV - startV) + dist)); }
		M_AddDistance := startV + ((UnitVec(endV -startV) * (Norm(endV -startV) + dist))); { is the same as the one above }
	END;