...Rotate a 3D Point?
Author: Arash Partow
const
PIDiv180 = 0.017453292519943295769236907684886;
procedure Rotate(Rx, Ry, Rz: Double; x, y, z: Double; var Nx, Ny, Nz: Double);
var
TempX: Double;
TempY: Double;
TempZ: Double;
SinX: Double;
SinY: Double;
SinZ: Double;
CosX: Double;
CosY: Double;
CosZ: Double;
XRadAng: Double;
YRadAng: Double;
ZRadAng: Double;
begin
XRadAng := Rx * PIDiv180;
YRadAng := Ry * PIDiv180;
ZRadAng := Rz * PIDiv180;
SinX := Sin(XRadAng);
SinY := Sin(YRadAng);
SinZ := Sin(ZRadAng);
CosX := Cos(XRadAng);
CosY := Cos(YRadAng);
CosZ := Cos(ZRadAng);
Tempy := y * CosY - z * SinY;
Tempz := y * SinY + z * CosY;
Tempx := x * CosX - Tempz * SinX;
Nz := x * SinX + Tempz * CosX;
Nx := Tempx * CosZ - TempY * SinZ;
Ny := Tempx * SinZ + TempY * CosZ;
end;
(* End Of *)
printed from
www.swissdelphicenter.ch
developers knowledge base