コード例 #1
0
        public static Path Rectangle(float width, float height, bool isCentered = true)
        {
            AXTurtle t = new AXTurtle();

            if (isCentered)
            {
                t.mov(-width / 2, -height / 2);
            }
            else
            {
                t.mov(0, 0);
            }

            t.dir(90);

            t.right(width);
            t.fwd(height);
            t.left(width);

            return(t.getPath());
        }
コード例 #2
0
        // BI_CHAMFER_SIDE

        public static Path BiChamferSide(float H          = 1,
                                         float R2         = 0,
                                         float R1         = 0,
                                         int SegsPer90    = 3,
                                         bool BevelOut    = true,
                                         float Taper      = 0,
                                         float TopLip     = 0,
                                         float BotLip     = 0,
                                         float LipEdge    = 0,
                                         float LipEdgeBot = 0,
                                         int Segs         = 1
                                         )
        {
            // DERIVED VARIABLES

            /*
             * float o      = H-(R1+R2);
             * float a      = Mathf.Atan2(o, Taper) * Mathf.Rad2Deg;
             *
             * float d      = Mathf.Sqrt(Taper*Taper + o*o);
             * float dr         = Mathf.Abs(R1-R2);
             * float b      = Mathf.Asin(dr/d) * Mathf.Rad2Deg;
             *
             * // his is the slope of the line or straight edge of the extrude side.
             * float dir        = (R2 > R1) ? 180 - (a+b)  : 270 - (a + (90-b));
             *
             * float s      = Mathf.Sqrt(d*d - dr*dr);
             */



            float o = H - (R1 + R2);
            float l = Taper + R2 - R1;

            float a = Mathf.Atan2(o, l) * Mathf.Rad2Deg;

            float d  = Mathf.Sqrt(l * l + o * o);
            float dr = Mathf.Abs(R1 - R2);
            float s  = Mathf.Sqrt(d * d - dr * dr);


            float b = Mathf.Asin(dr / d) * Mathf.Rad2Deg;

            // his is the slope of the line or straight edge of the extrude side.
            float dir = (R2 > R1) ? 180 - (a + b)  : 270 - (a + (90 - b));



            // START_X
            //float startX = 0;
            float startX = (R2 > R1) ? R2 - R1 : 0;

            startX -= BotLip;

            if (!BevelOut)
            {
                startX -= R1;
            }


            float startY = LipEdgeBot;


            // DRAW SHAPE

            AXTurtle t = new AXTurtle();

            t.mov(startX, startY);
            t.dir(90);

            if (LipEdgeBot != 0)
            {
                t.back(LipEdgeBot);
            }

            t.dir(0);

            if (BotLip > 0)
            {
                t.fwd(BotLip);
            }

            // Chamfer Bottom

            if (R1 > 0)
            {
                t.arcl(dir, R1, Mathf.FloorToInt((dir / 90f) * SegsPer90));
            }
            else
            {
                t.dir(dir);
            }

            for (int i = 0; i < Segs; i++)
            {
                t.fwd(s / Segs);
            }



            // Chamfer Top

            if (R2 > 0)
            {
                t.arcl((180 - dir), R2, Mathf.FloorToInt(((180 - dir) / 90f) * SegsPer90));
            }
            else
            {
                t.dir(180);
            }

            // TopLip
            if (TopLip > 0)
            {
                t.fwd(TopLip);
            }


            if (LipEdge != 0)
            {
                t.left(LipEdge);
            }


            return(t.path);
        }