wirewinder/gcode/Generator/Old/backup/combinedcalculation2.lpr
2025-01-10 12:27:32 +03:00

67 lines
2 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

program combinedcalculation2;
uses SysUtils, Math; // Для работы с math
var
length, width, angleDegrees, angleRadians, centerX, centerY, halfLength, halfWidth, leftBottomX, leftBottomY: real;
x0, y0, d, a, b, c, discriminant, t1, t2, theta1, theta2: real;
begin
length := 40.7;
width := 5.6;
angleDegrees := 15;
angleRadians := ((angleDegrees+90)) * Pi / 180;
centerX := 0;
centerY := 0;
halfLength := length / 2;
halfWidth := width / 2;
centerX := centerX - halfLength * Cos(angleRadians);
centerY := centerY - halfLength * Sin(angleRadians);
leftBottomX := centerX - halfLength * Cos(angleRadians) - halfWidth * Sin(angleRadians);
leftBottomY := centerY - halfLength * Sin(angleRadians) + halfWidth * Cos(angleRadians);
//leftBottomY := centerY - halfWidth * Sin(angleRadians) - halfLength * Cos(angleRadians);
writeln('Координаты левого нижнего угла: (', leftBottomX:0:6, ', ', leftBottomY:0:6, ')');
// Исходные данные
x0 := leftBottomY;
y0 := leftBottomX;
d := 0.825;
// Вычисление коэффициентов квадратного уравнения
a := x0 * x0 - d * d;
b := 2 * x0 * y0;
c := y0 * y0 - d * d;
// Вычисление дискриминанта
discriminant := b * b - 4 * a * c;
// Проверка наличия решений
if discriminant >= 0 then
begin
// Вычисление корней квадратного уравнения
t1 := (-b + sqrt(discriminant)) / (2 * a);
t2 := (-b - sqrt(discriminant)) / (2 * a);
// Вычисление углов в градусах
theta1 := ArcTan(t1) * 180 / Pi;
theta2 := ArcTan(t2) * 180 / Pi;
// Вывод результатов
writeln('Угол 1: ', theta1:0:10);
writeln('Угол 2: ', theta2:0:10);
end
else
begin
writeln('Дискриминант отрицательный, нет вещественных решений.');
end;
readln; // Чтобы консоль не закрылась сразу
end.