public void dome(Vector2 a, Vector2 b, float segs = 3, float tension = .3f) { float dt = 1f / (float)segs; Vector2 d = b - a; float hanx = tension * d.x; float hany = tension * d.y; // bezier 1 //Vector2 ha = new Vector2(a.x+hanx, a.y); //Vector2 hb = new Vector2(b.x, b.y-hany); Vector2 ha = new Vector2(a.x, a.y + hany); Vector2 hb = new Vector2(b.x - hanx, b.y); Vector2 pt; for (float i = 1; i <= segs; i++) { pt = AXTurtle.bezierValue(a, ha, hb, b, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } }
public void cymareversa(Vector2 a, Vector2 b, float segs = 3, float tension = .3f) { float dt = 1f / (float)segs; Vector2 d = b - a; Vector2 midpt = a + d / 2; float hanx = tension * d.x; float hany = tension * d.y; Vector2 pt; // bezier 1 Vector2 ha1 = new Vector2(a.x, a.y + hanx); Vector2 ha2 = new Vector2(midpt.x - hanx, midpt.y - hany / 2); for (float i = 1; i <= segs; i++) { pt = AXTurtle.bezierValue(a, ha1, ha2, midpt, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } // bezier 2 Vector2 hb1 = new Vector2(midpt.x + hanx, midpt.y + hany / 2); Vector2 hb2 = new Vector2(b.x, b.y - hany); for (float i = 1; i <= segs; i++) { pt = AXTurtle.bezierValue(midpt, hb1, hb2, b, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } }
public void bezier(Vector2 a, Vector2 b, Vector2 c, Vector2 d, int segs) { assertPath(a); float dt = 1f / (float)segs; for (float i = 1; i <= segs; i++) { Vector2 pt = AXTurtle.bezierValue(a, b, c, d, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } if (c.x == d.x && c.y != d.y) { if (c.y > d.y) { dir(270); } else { dir(90); } } else { dir(Mathf.Atan2(d.y - c.y, d.x - c.x) * Mathf.Rad2Deg); } }
public void onion(Vector2 a, Vector2 b, float segs = 3, float tension = .9f) { // VALIDATION: Assert at least 3 sides segs = Mathf.Max(segs, 3); float dt = 1f / (float)segs; Vector2 d = b - a; Vector2 midpt = a + d / 2; midpt.x = a.x - .2f * d.x; midpt.y = a.y + .5f * d.y; float hanx = 1.2f * Mathf.Abs(tension * d.x); float hany = .20f * Mathf.Abs(tension * d.y); Vector2 pt; // bezier 1 Vector2 ha1 = new Vector2(a.x + hanx, a.y); Vector2 ha2 = new Vector2(midpt.x + hanx, midpt.y - hany); for (float i = 1; i <= segs; i++) { pt = AXTurtle.bezierValue(a, ha1, ha2, midpt, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } // bezier 2 Vector2 hb1 = new Vector2(midpt.x - hanx, midpt.y + hany); Vector2 hb2 = new Vector2(b.x, b.y - .5f * hany); for (float i = 1; i <= segs; i++) { pt = AXTurtle.bezierValue(midpt, hb1, hb2, b, i * dt); path.Add(new IntPoint(sup(pt.x), sup(pt.y))); } }