Some changes
This commit is contained in:
parent
57455b84ab
commit
766bb1a985
103 changed files with 37820 additions and 2394 deletions
98
gcode/Generator/Old/combinedcalculation3.lpr
Normal file
98
gcode/Generator/Old/combinedcalculation3.lpr
Normal file
|
@ -0,0 +1,98 @@
|
|||
program combinedcalculation3;
|
||||
|
||||
uses SysUtils, Math;
|
||||
|
||||
const
|
||||
lengthConst = 40.7;
|
||||
widthConst = 5.6;
|
||||
angleDegreesConst = 15;
|
||||
distanceConst = 0.825;
|
||||
|
||||
|
||||
function CalculateMaxMinAngle(rodLength, rodWidth, angle, clearance: double): double;
|
||||
var
|
||||
angleRadians, leftBottomX, leftBottomY: double;
|
||||
leftBottomX2, leftBottomY2: double;
|
||||
a, b, c, discriminant, t1, t2, theta1, theta2: double;
|
||||
a2, b2, c2, discriminant2, t12, t22, theta12, theta22: double;
|
||||
begin
|
||||
CalculateMaxMinAngle := 0; // Изначально нет решений
|
||||
|
||||
angleRadians := (angle + 90) * Pi / 180;
|
||||
|
||||
leftBottomX := -rodLength / 2 * Cos(angleRadians) - rodLength / 2 * Cos(angleRadians) - rodWidth / 2 * Sin(angleRadians);
|
||||
leftBottomY := -rodLength / 2 * Sin(angleRadians) - rodLength / 2 * Sin(angleRadians) + rodWidth / 2 * Cos(angleRadians);
|
||||
|
||||
writeln('Coordinates bottom-left corner: (', leftBottomX:0:6, ', ', leftBottomY:0:6, ')');
|
||||
|
||||
leftBottomY2 := -rodLength / 2 * Cos(0) - rodLength / 2 * Cos(0) - rodWidth / 2 * Sin(0);
|
||||
leftBottomX2 := -rodLength / 2 * Sin(0) - rodLength / 2 * Sin(0) + rodWidth / 2 * Cos(0);
|
||||
|
||||
writeln('Coordinates second bottom-left corner: (', leftBottomX2:0:6, ', ', leftBottomY2:0:6, ')');
|
||||
|
||||
|
||||
a := sqr(leftBottomY) - sqr(clearance);
|
||||
b := 2 * leftBottomY * leftBottomX;
|
||||
c := sqr(leftBottomX) - sqr(clearance);
|
||||
|
||||
discriminant := sqr(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;
|
||||
|
||||
(* // Возвращаем меньший угол
|
||||
if theta1 < theta2 then
|
||||
CalculateMaxMinAngle := theta1
|
||||
else
|
||||
CalculateMaxMinAngle := theta2;*)
|
||||
|
||||
writeln('theta1: ', theta1:0:6);
|
||||
writeln('theta2: ', theta2:0:6);
|
||||
writeln();
|
||||
|
||||
if theta2 < theta1 then theta1 := theta2;
|
||||
|
||||
a2 := sqr(leftBottomY2) - sqr(clearance);
|
||||
b2 := 2 * leftBottomY2 * leftBottomX2;
|
||||
c2 := sqr(leftBottomX2) - sqr(clearance);
|
||||
|
||||
discriminant2 := sqr(b2) - 4 * a2 * c2;
|
||||
|
||||
if discriminant2 >= 0 then
|
||||
begin
|
||||
t12 := (-b2 + sqrt(discriminant2)) / (2 * a2);
|
||||
t22 := (-b2 - sqrt(discriminant2)) / (2 * a2);
|
||||
|
||||
theta12 := ArcTan(t12) * 180 / Pi;
|
||||
theta22 := ArcTan(t22) * 180 / Pi;
|
||||
|
||||
writeln('theta12: ', theta12:0:6);
|
||||
writeln('theta22: ', theta22:0:6);
|
||||
writeln();
|
||||
|
||||
|
||||
if theta22 > theta12 then theta12 := theta22;
|
||||
|
||||
CalculateMaxMinAngle:= (theta12 + theta22)/2;
|
||||
writeln('CalculateMaxMinAngle: ', CalculateMaxMinAngle:0:6);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
minAngle: double;
|
||||
begin
|
||||
minAngle := CalculateMaxMinAngle(lengthConst, widthConst, angleDegreesConst, distanceConst);
|
||||
|
||||
if minAngle <> 0 then
|
||||
writeln('Меньший угол: ', minAngle:0:10)
|
||||
else
|
||||
writeln('Дискриминант отрицательный, нет вещественных решений.');
|
||||
|
||||
readln;
|
||||
end.
|
Loading…
Add table
Add a link
Reference in a new issue