private bool IsCollision(IGeometry collidableElement, Point startPoint, Point endPoint, string connectionName, string collisionObjectName) { RayTracer rayTrace = new RayTracer(startPoint, endPoint); rayTrace.RayLineCreated = OnRayLineCreated; bool result = false; foreach (var vertex in collidableElement.Vertices) { foreach (var connection in vertex.VertexConnections) { Line line = new Line(connection.Vertex1.Position.Point, connection.Vertex2.Position.Point); rayTrace.Name = collisionObjectName; if (rayTrace.IsCollision(line)) { result = true; } } } if (result) { return(true); } else { return(false); } }