Пример #1
0
        private static Matrix3D GetElementTransformation(IMachineElement e)
        {
            if (e is IPanelElement pe)
            {
                return(pe.GetTransformation());
            }
            else if (e == null)
            //else if ((e == null) || (e.Transformation == null))
            //if ((e == null) || (e.Transformation == null))
            {
                return(Matrix3D.Identity);
            }
            else
            {
                var ts = (e.Transformation != null) ? StaticTransformationConverter.Convert(e.Transformation) : Matrix3D.Identity;

                if (e.LinkToParent != null)
                {
                    ts.Append(GetLinkTransformation(e.LinkToParent));
                }

                if (e.Parent is IToolholderBase th)
                {
                    var dt = DirectionToMatrixConverter.Convert(th.Direction);
                    var pt = StaticTransformationConverter.Convert(th.Position);

                    ts.Append(dt);
                    ts.Append(pt);
                }


                return(ts);
            }
        }
        public void Rotate(double x, double y, double z, double angle)
        {
            var v = _matrix.Transform(new Vector3D(x, y, z));
            var c = _matrix.Transform(_center);
            var tg = new Transform3DGroup();
            var tm = new MatrixTransform3D(_matrix);
            var tr = new RotateTransform3D(new QuaternionRotation3D(new Quaternion(v, angle)), c);

            tg.Children.Add(tm);
            tg.Children.Add(tr);

            _element.Transformation = StaticTransformationConverter.Convert(tg.Value);
        }
 public ElementRotator(IMachineElement element)
 {
     _element = element;
     _matrix = StaticTransformationConverter.Convert(element.Transformation);
     _center = GetCenter(element);
 }