Esempio n. 1
0
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            Window activeWindow = Window.ActiveWindow;
            Part   part         = activeWindow.Scene as Part;

            int    steps = 16;
            double step  = (double)1 / steps;

            for (int i = -steps; i <= steps; i++)
            {
                double u = (double)i * step;

                List <List <Body> > bands = new List <List <Body> >();

                for (int j = -steps; j <= steps; j++)
                {
                    double v = (double)j * step;

                    PointUV uv00 = PointUV.Create(u, v);
                    PointUV uv01 = PointUV.Create(u, v + step);
                    PointUV uv11 = PointUV.Create(u + step, v + step);
                    PointUV uv10 = PointUV.Create(u + step, v);

                    if (
                        uv00.MagnitudeSquared() > 1 ||
                        uv01.MagnitudeSquared() > 1 ||
                        uv11.MagnitudeSquared() > 1 ||
                        uv10.MagnitudeSquared() > 1
                        )
                    {
                        continue;
                    }

                    Point p00 = ToPoincare(uv00);
                    Point p01 = ToPoincare(uv01);
                    Point p11 = ToPoincare(uv11);
                    Point p10 = ToPoincare(uv10);

                    DesignCurve.Create(part, CurveSegment.Create(p00, p01));
                    DesignCurve.Create(part, CurveSegment.Create(p00, p10));
                }
            }

            activeWindow.ZoomExtents();
        }
Esempio n. 2
0
 public static double Magnitude(this PointUV pointUV)
 {
     return(Math.Sqrt(pointUV.MagnitudeSquared()));
 }