Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
    void OnEnable()
    {
        curveHandle = new CurveHandle();

        SceneView.onSceneGUIDelegate += OnSceneGUI;
    }