Skip to content

Commit

Permalink
Fix degenerated line direction
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejNepozitek committed Dec 13, 2023
1 parent 7232bd6 commit a692105
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ public List<OrthogonalLineGrid2D> RemoveIntersections(List<OrthogonalLineGrid2D>
}

public List<OrthogonalLineGrid2D> PartitionByIntersection(OrthogonalLineGrid2D line,
IList<OrthogonalLineGrid2D> intersection)
IList<OrthogonalLineGrid2D> intersection)
{
var result = new List<OrthogonalLineGrid2D>();
var rotation = line.ComputeRotation();
var rotatedLine = line.Rotate(rotation, true);
var rotatedLine = line.Rotate(rotation);
var directionVector = rotatedLine.GetDirectionVector();
var rotatedIntersection = intersection.Select(x => x.Rotate(rotation, false).GetNormalized()).ToList();
rotatedIntersection.Sort((x1, x2) => x1.From.CompareTo(x2.From));
Expand Down Expand Up @@ -228,18 +228,18 @@ public List<OrthogonalLineGrid2D> PartitionByIntersection(OrthogonalLineGrid2D l
if (intersectionLine.From != lastPoint && intersectionLine.From - directionVector != lastPoint)
{
result.Add(new OrthogonalLineGrid2D(lastPoint + directionVector,
intersectionLine.From - directionVector));
intersectionLine.From - directionVector, rotatedLine.GetDirection()));
}

lastPoint = intersectionLine.To;
}

if (rotatedLine.To != lastPoint && rotatedLine.To - directionVector != lastPoint)
{
result.Add(new OrthogonalLineGrid2D(lastPoint + directionVector, rotatedLine.To));
result.Add(new OrthogonalLineGrid2D(lastPoint + directionVector, rotatedLine.To, rotatedLine.GetDirection()));
}

return result.Select(x => x.Rotate(-rotation, false)).ToList();
return result.Select(x => x.Rotate(-rotation)).ToList();
}
}
}

0 comments on commit a692105

Please sign in to comment.