Use homogeneous coordinates to reduce floating point error when computing the intersection of self-intersecting line segments.
Partially addresses #57.
This commit is contained in:
parent
f58d3a8512
commit
4c2d0cb5ab
|
@ -342,7 +342,8 @@ impl<'a> Partitioner<'a> {
|
||||||
self.emit_b_quads_around_active_edge(upper_active_edge_index, crossing_point.x);
|
self.emit_b_quads_around_active_edge(upper_active_edge_index, crossing_point.x);
|
||||||
self.emit_b_quads_around_active_edge(lower_active_edge_index, crossing_point.x);
|
self.emit_b_quads_around_active_edge(lower_active_edge_index, crossing_point.x);
|
||||||
} else {
|
} else {
|
||||||
debug!("warning: swapped active edges {} & {} without finding intersection",
|
warn!("swapped active edges {} & {} without finding intersection; rendering \
|
||||||
|
will probably be incorrect",
|
||||||
upper_active_edge_index,
|
upper_active_edge_index,
|
||||||
lower_active_edge_index);
|
lower_active_edge_index);
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1010,8 @@ impl<'a> Partitioner<'a> {
|
||||||
let (lower_line, _) =
|
let (lower_line, _) =
|
||||||
Line::new(lower_left_vertex_position,
|
Line::new(lower_left_vertex_position,
|
||||||
lower_right_endpoint_position).subdivide_at_x(max_x);
|
lower_right_endpoint_position).subdivide_at_x(max_x);
|
||||||
upper_line.intersect_with_line(&lower_line)
|
// Use `intersect_at_infinity()` to reduce floating point error.
|
||||||
|
upper_line.intersect_at_infinity(&lower_line)
|
||||||
}
|
}
|
||||||
|
|
||||||
(upper_control_point_vertex_index, u32::MAX) => {
|
(upper_control_point_vertex_index, u32::MAX) => {
|
||||||
|
|
Loading…
Reference in New Issue