public bool IsInside(Vector2D v) { if (!boundingRectangle.IsInside(v)) { return(false); } Line2D ray = new Line2D(v, v + boundingRectangle.Width + 1.0f); List <Line2D> lines = GetLines(); int counter = 0; for (int i = 0; i < lines.Count; i++) { Vector2D dummy; if (ray.Intersect(lines[i], out dummy)) { counter++; } } return((counter % 2) == 1); }
public Line2D FindClosestIntersectionLine(Line2D intersectionLine) { List <Line2D> lines = GetLines(); double distance = double.MaxValue; Line2D result = null; for (int i = 0; i < lines.Count; i++) { Vector2D location; if (intersectionLine.Intersect(lines[i], out location)) { double dist = (location - intersectionLine.Start).Mag(); if (dist < distance) { result = lines[i]; distance = dist; } } } return(result); }