Originally Posted by
NecroDOME
yes... but I still have the same direction... I need to rotate the vector.
btw thanx, I also have some use for that
to rotate a vector (this is for 2D XY plane only):
Code:
procedure RotateVertexXY(var vector; const angle: decimal);
var
COORDS: array[0..1] of single absolute vector;
TEMP: array[0..1] of single;
AFUNC: array[0..1] of single;
anglerad: Single;
begin
TEMP[0]:= COORDS[0];
TEMP[1]:= COORDS[1];
anglerad:= degtorad(angle);
// caching is faster
AFUNC[0]:= Cos(anglerad);
AFUNC[1]:= Sin(anglerad);
COORDS[0]:= TEMP[0] * AFUNC[0] - TEMP[1] * AFUNC[1];
COORDS[1]:= TEMP[0] * AFUNC[1] + TEMP[1] * AFUNC[0];
end;
Bookmarks