public void VerifyAngleForRightSideLessThan90() { const double expected = Math.PI * 1.5; const double initialAngle = 0; var result = RadiansHelper.AngleForRightSide(initialAngle); Assert.AreEqual(expected, result, "Unexpected value for RHS angle."); }
public void VerifyAngleForLeftSideLessThan270() { const double expected = Math.PI; const double initialAngle = Math.PI / 2; var result = RadiansHelper.AngleForLeftSide(initialAngle); Assert.AreEqual(expected, result, "Unexpected value for LHS angle."); }
public void VerifyAngleForSideLeft() { const double expected = 0; const double initialAngle = Math.PI * 1.5; var result = RadiansHelper.AngleForSide(initialAngle, SidesOfCentre.Left); Assert.AreEqual(expected, result, "Unexpected value for LHS angle."); }
public void VerifyAngleForSideRight() { const double expected = Math.PI / 2; const double initialAngle = Math.PI; var result = RadiansHelper.AngleForSide(initialAngle, SidesOfCentre.Right); Assert.AreEqual(expected, result, "Unexpected value for RHS angle."); }
public void VerifyAnglesAreEqualAddTolerance() { const double tolerance = RadiansHelper.ANGLE_TOLERANCE / 2; const double angle1 = Math.PI; const double angle2 = angle1 + tolerance; var result = RadiansHelper.AnglesAreEqual(angle1, angle2); Assert.True(result, "Angles should be equal."); }
public void VerifyAnglesAreNotEqualMinusTolerance() { const double tolerance = RadiansHelper.ANGLE_TOLERANCE * 1.5; const double angle1 = Math.PI; const double angle2 = angle1 - tolerance; var result = RadiansHelper.AnglesAreEqual(angle1, angle2); Assert.False(result, "Angles should not be equal."); }
public void VerifyAngleForInvalidSide() { const double initialAngle = Math.PI * 1.5; bool result; try { RadiansHelper.AngleForSide(initialAngle, (SidesOfCentre)999); result = false; } catch (ArgumentOutOfRangeException) { result = true; } Assert.IsTrue(result, "Side of centre should be invalid."); }
public static double AngleFromCurveToForSide(this Curve curve, SidesOfCentre side) { double curveAngle; switch (curve) { case Line line: curveAngle = line.Angle; break; case Arc arc: var startPoint = new Point2d(arc.StartPoint.X, arc.StartPoint.Y); var arcCentre = new Point2d(arc.Center.X, arc.Center.Y); var startVector = arcCentre.GetVectorTo(startPoint); curveAngle = arc.Clockwise() ? startVector.Angle - RadiansHelper.DEGREES_90 : startVector.Angle + RadiansHelper.DEGREES_90; break; default: throw new ArgumentOutOfRangeException(nameof(curve), curve, null); } return(RadiansHelper.AngleForSide(curveAngle, side)); }