public gEdge(gVertex start, gVertex end) { StartVertex = start; EndVertex = end; Length = StartVertex.DistanceTo(EndVertex); Direction = gVector.ByTwoVertices(StartVertex, EndVertex); }
public bool ContainsVertex(gVertex vertex) { gVertex maxVertex = vertices.OrderByDescending(v => v.DistanceTo(vertex)).First(); double maxDistance = vertex.DistanceTo(maxVertex) * 1.5; gVertex v2 = gVertex.ByCoordinates(vertex.X + maxDistance, vertex.Y, vertex.Z); gEdge ray = gEdge.ByStartVertexEndVertex(vertex, v2); gVertex coincident = null; int windNumber = 0; foreach (gEdge edge in edges) { gBase intersection = ray.Intersection(edge); if (edge.StartVertex.Y <= vertex.Y) { if (edge.EndVertex.Y > vertex.Y && intersection != null && intersection.GetType() == typeof(gVertex)) { ++windNumber; } } else { if (edge.EndVertex.Y <= vertex.Y && intersection != null && intersection.GetType() == typeof(gVertex)) { --windNumber; } } } //If intersections is odd, returns true, false otherwise //return (intersections % 2 == 0) ? false : true; return(windNumber != 0); }
public double DistanceTo(gVertex vertex) { return(vertex.DistanceTo(this)); }