示例#1
0
        public static IMesh Rotate(IMesh mesh, double angle, IPoint3D origin, IVector3D axis)
        {
            IMesh       dup = mesh.DeepCopy();
            ITransformX T;
            IPoint3D    pt;

            foreach (int vK in dup.VerticesKeys)
            {
                pt = mesh.GetVertexWithKey(vK).Position;
                T  = new ITransformX();
                T.RotateAboutAxis(angle, origin, axis);
                pt.Transform(T);
                dup.SetVertexPosition(vK, pt);
            }

            dup.UpdateGraphics();

            return(dup);
        }
示例#2
0
        public static IMesh Twist(IMesh mesh, Line axis, double angleFactor)
        {
            IMesh       dM = mesh.DeepCopy();
            IPoint3D    pt;
            double      d;
            ITransformX T;
            IPoint3D    origin    = new IPoint3D(axis.FromX, axis.FromY, axis.FromZ);
            IVector3D   direction = IVector3D.CreateVector(axis.To, axis.From);

            foreach (int vK in dM.VerticesKeys)
            {
                pt = dM.GetVertexWithKey(vK).Position;
                d  = axis.DistanceTo(pt.RhinoPoint, true);
                T  = new ITransformX();
                T.RotateAboutAxis(d * angleFactor, origin, direction);
                pt.Transform(T);

                dM.SetVertexPosition(vK, pt);
            }

            dM.UpdateGraphics();

            return(dM);
        }