30 lines
643 B
ObjectPascal
30 lines
643 B
ObjectPascal
program rotatepoint;
|
|
uses Math;
|
|
|
|
var
|
|
x, y, angleDegrees, rotatedX, rotatedY: real;
|
|
|
|
function rotatePoint(x, y, angle: real; var rotatedX_out, rotatedY_out: real): real;
|
|
var
|
|
angleRadians: real;
|
|
begin
|
|
angleRadians := degToRad(-angle);
|
|
rotatedX_out := x * cos(angleRadians) - y * sin(angleRadians);
|
|
rotatedY_out := x * sin(angleRadians) + y * cos(angleRadians);
|
|
end;
|
|
|
|
function degToRad(deg: real): real;
|
|
begin
|
|
degToRad := deg * pi / 180;
|
|
end;
|
|
|
|
begin
|
|
x := -27.9;
|
|
y := -1.2;
|
|
angleDegrees := 15;
|
|
|
|
rotatePoint(x, y, angleDegrees, rotatedX, rotatedY);
|
|
|
|
writeln('Rotated x: ', rotatedX:0:5, ', y: ', rotatedY:0:5);
|
|
readln;
|
|
end.
|