void renderSegment(Renderer.BaseRenderer g, LPoint p1, LPoint p2, float quality, float border) { if (p1.Outside && p2.Outside) { return; } if (Spline != null) { int n = (int)(p1.Dist(p2) * quality); float dx = (p2.X - p1.X) / n; float dy = (p2.Y - p1.Y) / n; float dr = (p2.Rad - p1.Rad) / n; for (int i = 0; i < n; i++) { double x, y; Spline.GetPoint(p1.Index + i / (float)n, out x, out y); LPoint p = new LPoint((float)x, (float)y, p1.Rad + dr * i); renderPoint(g, p, border); } } else { int n = (int)(p1.Dist(p2) * quality); float dx = (p2.X - p1.X) / n; float dy = (p2.Y - p1.Y) / n; float dr = (p2.Rad - p1.Rad) / n; for (int i = 0; i < n; i++) { LPoint p = new LPoint(p1.X + dx * i, p1.Y + dy * i, p1.Rad + dr * i); renderPoint(g, p, border); } } }
public virtual bool Collision(LPoint pt) { if (!Bounds.Expand(pt.Rad).Contains(pt.X, pt.Y)) { return(false); } double x, y; if (Points.Count > 1) { for (int i = 0; i < Points.Count - 1; i++) { float dist = Points[i].Dist(Points[i + 1]); float rad = Math.Max(Points[i].Rad, Points[i + 1].Rad); for (float t = i; t < i + 1; t += 10f / dist) { if (Spline != null) { Spline.GetPoint(t, out x, out y); } else { x = Points[i].X * (t - i) + Points[i + 1].X * (1 - t + i); y = Points[i].Y * (t - i) + Points[i + 1].Y * (1 - t + i); } if (pt.Dist((float)x, (float)y) < rad + pt.Rad) { return(true); } } } } else if (Points.Count == 1) { if (pt.Dist(Points[0]) < pt.Rad + pt.Rad) { return(true); } } return(false); }