removed unnecessary things

This commit is contained in:
MarcUs7i 2024-10-09 17:37:52 +02:00
parent f316a9b3ec
commit 2a1e796efb

View file

@ -1,4 +1,5 @@
using System.Reflection.Metadata;
using System.Collections.Immutable;
using System.Reflection.Metadata;
using Avalonia.Controls.Selection;
using LeoTurtle;
@ -27,8 +28,6 @@ public static class PinwheelTilingPath
_endPoint = new Point(_startPoint.X + sideB, _startPoint.Y + sideA);
Triangle triangle = MakeTriangle(_startPoint, _endPoint);
/*Triangle[] subdivision = GetSubdivision(triangle);
DrawSubdivision(turtle, subdivision);*/
MakeRecursiveTriangle(turtle, triangle, depth);
}
@ -62,8 +61,8 @@ public static class PinwheelTilingPath
private static Triangle[] GetSubdivision(Triangle triangle)
{
double sideA = triangle.B.Y - triangle.C.Y;
double sideB = triangle.C.X - triangle.A.X;
double sideA = DistanceBetweenPoints(triangle.B, triangle.C);
double sideB = DistanceBetweenPoints(triangle.A, triangle.C);
double sideC = CalculateHyptonuse(sideA, sideB);
Point startingPoint = new Point(triangle.A.X, triangle.A.Y);
Point endingPoint = new Point(triangle.B.X, triangle.B.Y);
@ -108,14 +107,9 @@ public static class PinwheelTilingPath
return subdivisionTriangles;
double CalculateHeight(double a, double b, double c)
{
//using Heron's formula
double s = (a + b + c) / 2;
return (2 / c) * Math.Sqrt(s * (s - a) * (s - b) * (s - c));
}
double CalculateHeight(double a, double b, double c) => a * b / c;
}
private static void DrawSubdivision(SmartTurtle turtle, Triangle[] subdivision)
{
foreach (var triangle in subdivision)
@ -141,43 +135,6 @@ public static class PinwheelTilingPath
turtle.LookAt(triangle.A.X, triangle.A.Y);
turtle.MoveForward(sideCA);
}
private static void DrawTriangle(SmartTurtle turtle, double a, double b, double c, double h, double e, double f)
{
//Draw base triangle
turtle.Teleport(_startPoint.X, _startPoint.Y);
turtle.Turn(90);
DrawLine(turtle, b, -Gamma);
DrawLine(turtle, a, -(Gamma + Alpha));
DrawLine(turtle, c);
//Draw the height
turtle.Teleport(_endPoint.X, _startPoint.Y);
turtle.Turn(-Alpha);
DrawLine(turtle, e, -90);
double[] halfHeightPosition = turtle.GetPosition();
DrawLine(turtle, h);
turtle.Teleport(halfHeightPosition[0], halfHeightPosition[1]);
turtle.Turn(-Alpha);
DrawLine(turtle, e, -(90 + Alpha));
DrawLine(turtle, f);
//reset angle
ResetAngle(turtle);
turtle.Turn(-Alpha);
DrawLine(turtle, e);
void DrawLine(SmartTurtle turtle, double distance, double angle = 0)
{
turtle.MoveForward(distance);
turtle.Turn(angle);
}
void ResetAngle(SmartTurtle turtle)
{
turtle.Teleport(turtle.GetPosition()[0], turtle.GetPosition()[1]);
}
}
private static double CalculateHyptonuse(double a, double b)
{