public static void SetHandleTip() { double tolerance = 0.0001; CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5, tolerance); double radius = 5; Angle rotation = new Angle(Numbers.PiOver4); CurveHandle curveHandle = new CurveHandle(controlPoint, radius, rotation); Assert.AreEqual(controlPoint, curveHandle.ControlPoint); Assert.AreEqual(radius, curveHandle.Radius); Assert.AreEqual(rotation, curveHandle.Rotation); CartesianCoordinate expectedHandleTip = new CartesianCoordinate(5.53553, 8.53553, tolerance); CartesianCoordinate handleTip = curveHandle.GetHandleTip(); Assert.AreEqual(expectedHandleTip, handleTip); CartesianCoordinate newHandleTipExpected = new CartesianCoordinate(2, 7, tolerance); curveHandle.SetHandleTip(newHandleTipExpected); CartesianCoordinate newHandleTip = curveHandle.GetHandleTip(); Assert.AreEqual(controlPoint, curveHandle.ControlPoint); Assert.AreEqual(2, curveHandle.Radius); Assert.AreEqual(Numbers.PiOver2, curveHandle.Rotation.Radians, Tolerance); Assert.AreEqual(newHandleTipExpected, newHandleTip); }
/// <summary> /// Initializes a new instance of the <see cref="BezierCurve"/> class. /// </summary> /// <param name="handleStart">The handle start.</param> /// <param name="handleEnd">The handle end.</param> /// <param name="numberOfControlPoints">The number of control points.</param> /// <param name="tolerance">Tolerance to apply to the curve.</param> public BezierCurve(CurveHandle handleStart, CurveHandle handleEnd, int numberOfControlPoints = _maxNumberOfControlPoints, double tolerance = DEFAULT_TOLERANCE) : base(tolerance) { NumberOfControlPoints = getNumberOfControlPoints(numberOfControlPoints); HandleI = handleStart; HandleJ = handleEnd; }
public static void ToString_Returns_Overridden_Value() { CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5); double radius = 5; Angle rotation = new Angle(Numbers.PiOver4); CurveHandle curveHandle = new CurveHandle(controlPoint, radius, rotation); Assert.AreEqual("MPT.Math.Curves.Tools.CurveHandle - Center: {X: 2, Y: 5} - Radius: 5, Rotation: 45 deg", curveHandle.ToString()); }
public static void Initialize_with_Control_Point_and_Radius() { CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5); double radius = 5; CurveHandle curveHandle = new CurveHandle(controlPoint, radius); Assert.AreEqual(controlPoint, curveHandle.ControlPoint); Assert.AreEqual(radius, curveHandle.Radius); Assert.AreEqual(Angle.Origin(), curveHandle.Rotation); }
public static void Initialize_with_Control_Point_and_Radius_and_Rotation() { CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5); double radius = 5; Angle rotation = new Angle(Numbers.PiOver4); CurveHandle curveHandle = new CurveHandle(controlPoint, radius, rotation); Assert.AreEqual(controlPoint, curveHandle.ControlPoint); Assert.AreEqual(radius, curveHandle.Radius); Assert.AreEqual(rotation, curveHandle.Rotation); }
/// <summary> /// Initializes a new instance of the <see cref="BezierCurve"/> class. /// </summary> /// <param name="pointI">The point i.</param> /// <param name="pointJ">The point j.</param> /// <param name="numberOfControlPoints">The number of control points.</param> /// <param name="tolerance">Tolerance to apply to the curve.</param> public BezierCurve( CartesianCoordinate pointI, CartesianCoordinate pointJ, int numberOfControlPoints = _maxNumberOfControlPoints, double tolerance = DEFAULT_TOLERANCE) : base(tolerance) { NumberOfControlPoints = getNumberOfControlPoints(numberOfControlPoints); double handleLength = getHandleLength(pointI, pointJ); HandleI = new CurveHandle(pointI, handleLength); HandleJ = getCurveHandleJ(pointJ, handleLength); }
public static void GetHandleTip() { double tolerance = 0.0001; CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5, tolerance); double radius = 5; Angle rotation = new Angle(Numbers.PiOver4); CurveHandle curveHandle = new CurveHandle(controlPoint, radius, rotation); CartesianCoordinate expectedHandleTip = new CartesianCoordinate(5.53553, 8.53553, tolerance); CartesianCoordinate handleTip = curveHandle.GetHandleTip(); Assert.AreEqual(expectedHandleTip, handleTip); }
public static void CloneCurve() { CartesianCoordinate controlPoint = new CartesianCoordinate(2, 5); double radius = 5; Angle rotation = new Angle(Numbers.PiOver4); CurveHandle curveHandle = new CurveHandle(controlPoint, radius, rotation); Assert.AreEqual(controlPoint, curveHandle.ControlPoint); Assert.AreEqual(radius, curveHandle.Radius); Assert.AreEqual(rotation, curveHandle.Rotation); CurveHandle clonedCurveHandle = curveHandle.CloneCurve(); Assert.AreEqual(controlPoint, clonedCurveHandle.ControlPoint); Assert.AreEqual(radius, clonedCurveHandle.Radius); Assert.AreEqual(rotation, clonedCurveHandle.Rotation); }
void OnEnable() { curveHandle = new CurveHandle(); SceneView.onSceneGUIDelegate += OnSceneGUI; }