I believe the current rsweep code is incorrect when using negative angles less than a full rotation.
This example code:
let vertex = builder::vertex(Point3::new(1.0, 0.0, 0.0));
let circle = builder::rsweep(&vertex, Point3::origin(), Vector3::unit_z(), Rad(7.0));
let circle = translated(&circle, 2.0 * Vector3::unit_x());
let disk = builder::try_attach_plane(&vec![circle]).unwrap();
let solid = builder::rsweep(&disk, Point3::origin(), Vector3::unit_y(), -Rad(1.0));
render_to("foo.obj", solid);
yields a full torus even though the sweep angle is only -1 radian:
This commit changes the conditional so that:
whole_sweep is always called when the absolute value of the angle is 2 Pi or greater
partial_sweep is always given a positive angle
In both cases negative input angles are handled by inverting the rotation axis.
After this commit, the code above yields a non-inverted object:
I wasn't sure the best way to add a test, but if you tell me how you'd like to do it I can add an additional commit to this PR.
My best idea is to do the partial sweep with negative angle and check that the resulting solid's mesh is closed, but I don't know if meshing is perhaps too expensive to add in the test suite and another approach would be preferred.
I believe the current rsweep code is incorrect when using negative angles less than a full rotation.
This example code:
yields a full torus even though the sweep angle is only -1 radian:
This commit changes the conditional so that:
whole_sweep
is always called when the absolute value of the angle is 2 Pi or greaterpartial_sweep
is always given a positive angleIn both cases negative input angles are handled by inverting the rotation axis.
After this commit, the code above yields a non-inverted object:
I wasn't sure the best way to add a test, but if you tell me how you'd like to do it I can add an additional commit to this PR. My best idea is to do the partial sweep with negative angle and check that the resulting solid's mesh is closed, but I don't know if meshing is perhaps too expensive to add in the test suite and another approach would be preferred.