alvpickmans/Graphical

Intersection between edges error when perpendicular and intersecting

Closed this issue · 0 comments

When doing edge1.Intersection(edge2) and edge1 is perpendicular to edge2 and intersecting on one of edge1's vertex, returned intersection is that vertex. On this case the dot product is also 0 but they are not parallel.

// if dot == 0 it means that they are parallels
if(Threshold(dot, 0))
{
//Fully contains the test edge
if(edge.StartVertex.OnEdge(this) && edge.EndVertex.OnEdge(this))
{
return edge;
}
else if(this.StartVertex.OnEdge(edge) || this.EndVertex.OnEdge(edge))
{
gVertex[] vertices = new gVertex[4]
{
this.StartVertex,
this.EndVertex,
edge.StartVertex,
edge.EndVertex
};
var sorted = vertices.OrderBy(v => v.Y).ThenBy(v => v.X).ThenBy(v => v.Z).ToList();
return gEdge.ByStartVertexEndVertex(sorted[1], sorted[2]);
}
else
{
return null;
}
}

Dynamo recreation
image