예제 #1
0
        /// <summary>
        ///   Check if the Node translation is set to value translation
        /// </summary>
        /// <param name = "node">Node who has a translation to test</param>
        /// <param name = "translation">The translation value that the node should have</param>
        public static bool CheckNodeTranslationAgainst(Node node, Point3D translation)
        {
            var transformation        = node.Get <TransformationInterpreter>();
            var translatedOriginPoint = OriginCoordinate.Transformed(transformation.CurrTransform);

            return(translatedOriginPoint.IsEqual(translation.GpPnt, Precision.Confusion));
        }
예제 #2
0
        public void Rotation45DegreesOnZTest()
        {
            var node = new Node();

            node.Set <TransformationInterpreter>();
            var interpreter = node.Get <TransformationInterpreter>();

            // Disable parent notification
            interpreter.Disable();

            interpreter.Pivot  = new gpPnt(100, 100, 0);
            interpreter.Rotate = new gpPnt(0, 0, 45);
            var curTransform = interpreter.CurrTransform;

            var rotatedPoint = _originCoordinate.Transformed(curTransform);

            Assert.IsTrue(Math.Abs(100 - rotatedPoint.X) < 0.1, "incorrect rotation on x axis");
            Assert.IsTrue(Math.Abs(-41.42 - rotatedPoint.Y) < 0.1, "incorrect rotation on y axis");
            Assert.IsTrue(Math.Abs(0 - rotatedPoint.Z) < 0.1, "incorrect rotation on z axis");
        }
        public void TransformationInterpreterTwoTransformationSetupsTest()
        {
            var testPoint       = new Point3D(100, 100, 100);
            var trsf            = GeomUtils.BuildTranslation(new Point3D(_originCoordinate), testPoint);
            var trsfInterpreter = new TransformationInterpreter();

            trsfInterpreter.Disable();

            trsfInterpreter.CurrTransform = trsf;

            var translatedPoint = _originCoordinate.Transformed(trsfInterpreter.CurrTransform);

            Assert.AreEqual(translatedPoint.IsEqual(testPoint.GpPnt, Precision.Confusion), true,
                            "Broken transformation interpreter");

            var testPoint2 = new Point3D(200, 200, 200);

            trsf = GeomUtils.BuildTranslation(new Point3D(_originCoordinate), testPoint2);
            trsfInterpreter.CurrTransform = trsf;
            translatedPoint = _originCoordinate.Transformed(trsfInterpreter.CurrTransform);
            Assert.AreEqual(translatedPoint.IsEqual(testPoint2.GpPnt, Precision.Confusion), true,
                            "Broken transformation interpreter at second Trsf set");
        }
예제 #4
0
        public void SetTransformationTestTranslationOnZ()
        {
            var originBaseSketch   = new gpPnt(1, 1, 0);
            var originSecondSketch = new gpPnt(2, 2, 10);
            var T             = new gpTrsf();
            var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1));
            var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(0, 0, 1));

            T.SetTransformation(oldSystemAxis, newSystemAxis);
            var secondOriginTransformed = originSecondSketch.Transformed(T);

            Assert.AreEqual(secondOriginTransformed.X, originBaseSketch.X);
            Assert.AreEqual(secondOriginTransformed.Y, originBaseSketch.Y);
            Assert.AreEqual(secondOriginTransformed.Z, originBaseSketch.Z);
            var point = new gpPnt(2, 3, 10).Transformed(T);

            Assert.AreEqual(point.X, 1);
            Assert.AreEqual(point.Y, 2);
            Assert.AreEqual(point.Z, 0);
        }