public Angle(float value, AngleType angleType = AngleType.Degree) { switch (angleType) { case AngleType.Degree: _degrees = value < 0 ? value % 361 + 360 : value % 361; break; case AngleType.Gradian: value = AngleHelper.GradianToDegree(value); _degrees = value < 0 ? value % 361 + 360 : value % 361; break; case AngleType.Radian: value = AngleHelper.RadianToDegree(value); _degrees = value < 0 ? value % 361 + 360 : value % 361; break; case AngleType.Turn: value = AngleHelper.TurnToDegree(value); _degrees = value < 0 ? value % 361 + 360 : value % 361; break; default: _degrees = 0f; break; } }
public Ray2D(ICoordinates startPoint, Angle angle) { _startPoint = (Vector2D)startPoint; _angleFromXAxis = angle; Slope = AngleHelper.AngleToSlope(angle); YAt0 = startPoint.Y - Slope * startPoint.X; }
public Ray2D(Point point2D, Angle angle) { _startPoint = (Vector2D)point2D; _angleFromXAxis = angle; Slope = AngleHelper.AngleToSlope(angle); YAt0 = point2D.Y - Slope * point2D.X; }
public static double DistanceBetween(Segment segment1, Segment segment2) { if (Intersects(segment1, segment2)) { return(0); } if (segment1.Slope == segment2.Slope) { return(Math.Sin(AngleHelper.SlopeToRadian(segment1.Slope)) * (segment1.Slope * Math.Abs(segment1.YAt0 - segment2.YAt0))); } if (segment1.Slope > segment2.Slope) { return(DistanceBetween(segment1.Point2, segment2.Point2)); } return(DistanceBetween(segment1.Point1, segment2.Point1)); }
public Angle(Vector2 vector) { _degrees = AngleHelper.RadianToDegree((float)Math.Atan2(-vector.Y, vector.X)); }
public Vector2 GetVector(float vectorLenght) => AngleHelper.DegreeToVector(_degrees, vectorLenght);
public Vector2 GetUnitVector() => AngleHelper.DegreeToVector(_degrees, 1);
public Line(ICoordinates point, Angle angle) { Slope = AngleHelper.AngleToSlope(angle); YAt0 = point.Y - point.X * Slope; }