From dc64135b7076c6749b2518a6acc5eacefd4ba393 Mon Sep 17 00:00:00 2001 From: spsarras Date: Wed, 18 Dec 2024 13:33:08 +0200 Subject: [PATCH] refactor: used static XAxis and extract method for RadiansToDegrees --- GsaGH/Parameters/0_Model/GsaGridLine.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GsaGH/Parameters/0_Model/GsaGridLine.cs b/GsaGH/Parameters/0_Model/GsaGridLine.cs index 968449d7c..4ba949335 100644 --- a/GsaGH/Parameters/0_Model/GsaGridLine.cs +++ b/GsaGH/Parameters/0_Model/GsaGridLine.cs @@ -62,7 +62,8 @@ public GsaGridLine(Arc arc, string label = "") { public GsaGridLine(Line line, string label = "") { bool IsCounterClockwise = Vector3d.CrossProduct(Vector3d.XAxis, line.UnitTangent).Z > 0; - double vectorAngle = Vector3d.VectorAngle(new Vector3d(1, 0, 0), line.UnitTangent) * 180 / Math.PI; + double radians = Vector3d.VectorAngle(Vector3d.XAxis, line.UnitTangent); + double vectorAngle = RadiansToDegrees(radians); if (!IsCounterClockwise) { vectorAngle = 360 - vectorAngle; } @@ -80,6 +81,11 @@ public GsaGridLine(Line line, string label = "") { UpdatePreview(); } + private static double RadiansToDegrees(double radians) + { + return radians * 180 / Math.PI; + } + internal static Arc ToArc(GridLine gridLine) { var center = new Point3d(gridLine.X, gridLine.Y, 0); double angleRadians = (gridLine.Theta2 - gridLine.Theta1) * Math.PI / 180.0;