Пример #1
0
        public void SetTransformationTestRotationAndTranslation()
        {
            var originBaseSketch   = new gpPnt(1, 1, 0);
            var originSecondSketch = new gpPnt(10, 1, 0);
            var T             = new gpTrsf();
            var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1));
            var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(1, 0, 0));

            T.SetTransformation(oldSystemAxis, newSystemAxis);

            var point = new gpPnt(10, 3, 8).Transformed(T);

            var translationPart = new gpTrsf();

            translationPart.SetTranslation(new gpPnt(0, 0, 0), point);
            gpTrsf mult1 = T.Inverted.Multiplied(translationPart);
            var    try1  = new gpPnt(0, 0, 0).Transformed(mult1); // ok

            Assert.AreEqual(try1.X, 10);
            Assert.AreEqual(try1.Y, 3);
            Assert.AreEqual(try1.Z, 8);
            gpTrsf mult2 = translationPart.Multiplied(T.Inverted);
            var    try2  = new gpPnt(0, 0, 0).Transformed(mult2); // nok

            Assert.AreEqual(try2.X, 17);
            Assert.AreEqual(try2.Y, -3);
            Assert.AreEqual(try2.Z, 1);
        }
Пример #2
0
        private void GetRotateValue(ref object resultvalue)
        {
            var nb = new NodeBuilder(Parent);

            if (nb.FunctionName != FunctionNames.Sketch)
            {
                return;
            }

            var interpreter = Parent.Get <TransformationInterpreter>();

            if (interpreter == null)
            {
                return;
            }
            var transformations = NodeBuilderUtils.GetTransformations(nb);
            var multiplied      = new gpTrsf();

            foreach (var trsf in transformations)
            {
                multiplied = multiplied.Multiplied(trsf);
            }
            var matr = multiplied.VectorialPart;
            // extract rotation from matrix
        }
Пример #3
0
        public void SetTransformationTestMultipleTrsf()
        {
            var originBaseSketch   = new gpPnt(1, 1, 0);
            var originSecondSketch = new gpPnt(10, 1, 0);

            var T             = new gpTrsf();
            var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1));
            var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(1, 0, 0));

            T.SetTransformation(oldSystemAxis, newSystemAxis);

            var point = new gpPnt(10, 3, 8).Transformed(T);

            var translationPart = new gpTrsf();

            translationPart.SetTranslation(new gpPnt(0, 0, 0), point);
            gpTrsf mult1 = T.Inverted.Multiplied(translationPart);
            var    try1  = new gpPnt(0, 0, 0).Transformed(mult1); // ok: transformations needed to obtain global point (10, 3, 8)

            Assert.AreEqual(try1.X, 10);
            Assert.AreEqual(try1.Y, 3);
            Assert.AreEqual(try1.Z, 8);

            //reversed order doesn't work
            gpTrsf mult2 = translationPart.Multiplied(T.Inverted);
            var    try2  = new gpPnt(0, 0, 0).Transformed(mult2);

            Assert.AreEqual(try2.X, 17);
            Assert.AreEqual(try2.Y, -3);
            Assert.AreEqual(try2.Z, 1);

            //translate entire 'object'
            var translation1 = new gpTrsf();

            translation1.SetTranslation(new gpPnt(1, 1, 0), new gpPnt(7, 1, 0));
            var multipleTrsfs = translation1.Multiplied(mult1);
            var try11         = new gpPnt(0, 0, 0).Transformed(multipleTrsfs);

            Assert.AreEqual(try11.X, 16);
            Assert.AreEqual(try11.Y, 3);
            Assert.AreEqual(try11.Z, 8);

            //reversed order doesn't work
            var multipleTrsfs2 = mult1.Multiplied(translation1);
            var try12          = new gpPnt(0, 0, 0).Transformed(multipleTrsfs2);

            Assert.AreEqual(try12.X, 10);
            Assert.AreEqual(try12.Y, 3);
            Assert.AreEqual(try12.Z, 14);
        }
Пример #4
0
        private static void ApplyTranslate(gpPnt currentLocation, Point3D increment, Node sketchNode)
        {
            var currentAxis = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode));

            var trsfCurrent = sketchNode.Get <TransformationInterpreter>().CurrTransform;
            var newPosition = new Point3D(currentAxis.Location.X + increment.X,
                                          currentAxis.Location.Y + increment.Y,
                                          currentAxis.Location.Z + increment.Z);
            var    newSystemAxis = new gpAx3(newPosition.GpPnt, currentAxis.Direction);
            gpTrsf T             = new gpTrsf();

            T.SetDisplacement(new gpAx3(currentAxis.Location, currentAxis.Direction), newSystemAxis);

            trsfCurrent = T.Multiplied(trsfCurrent);
            sketchNode.Set <TransformationInterpreter>().CurrTransform = trsfCurrent;
            var nb = new NodeBuilder(sketchNode);

            nb.ExecuteFunction();
        }