This commit is contained in:
Hanno Braun 2023-02-15 14:51:22 +01:00
parent 6a442037d3
commit 0bbd5ab911

View File

@ -63,14 +63,14 @@ impl Arc {
let unit_vector_midpoint_to_center = let unit_vector_midpoint_to_center =
Vector::from([-unit_vector_p0_to_p1.v, unit_vector_p0_to_p1.u]); Vector::from([-unit_vector_p0_to_p1.v, unit_vector_p0_to_p1.u]);
// (cx, cy) is the center of the circle // (cx, cy) is the center of the circle
let cx = ((x0 + x1) / 2.) let center = Point {
+ distance_center_to_midpoint * unit_vector_midpoint_to_center.u; coords: (p0.coords + p1.coords) / 2.
let cy = ((y0 + y1) / 2.) + unit_vector_midpoint_to_center * distance_center_to_midpoint,
+ distance_center_to_midpoint * unit_vector_midpoint_to_center.v; };
let start_angle = (y0 - cy).atan2(x0 - cx); let start_angle = (y0 - center.v).atan2(x0 - center.u);
let end_angle = (y1 - cy).atan2(x1 - cx) + end_angle_offset; let end_angle = (y1 - center.v).atan2(x1 - center.u) + end_angle_offset;
Self { Self {
center: Point::from([cx, cy]), center,
radius, radius,
start_angle, start_angle,
end_angle, end_angle,