Revert "角度"

This reverts commit acfe44fd2e.
qdj
邱德佳 3 months ago
parent acfe44fd2e
commit 394658142d

@ -4,18 +4,6 @@ use dxf::entities::LwPolyline;
use hex_color::HexColor;
use simple_xml_builder::XMLElement;
fn normalize_angle(angle: f64) -> f64 {
let mut norm = angle % 360.0;
if norm < 0.0 {
norm += 360.0;
}
norm
}
fn qet_start_angle(angle: f64) -> f64 {
normalize_angle(270.0 - angle)
}
#[derive(Debug)]
pub struct Arc {
//need to brush up on my Rust scoping rules, isn't there a way to make this pub to just the module?
@ -86,7 +74,7 @@ impl Arc {
y: -arc.center.y - arc.radius,
height: arc.radius * 2.0,
width: arc.radius * 2.0,
start: qet_start_angle(normalize_angle(start_angle)),
start: if start_angle < 0.0 { -start_angle } else { start_angle },
angle: if angle_span < 0.0 { -angle_span } else { angle_span },
//in the original code antialias is always set to false...I'm guessing for performance
@ -287,8 +275,18 @@ impl Arc {
(start_y_qet - center_y_qet).atan2(start.0 - center_x).to_degrees();
let mut end_angle = (end_y_qet - center_y_qet).atan2(end.0 - center_x).to_degrees();
start_angle = normalize_angle(start_angle);
end_angle = normalize_angle(end_angle);
let normalize = |mut angle: f64| {
while angle < 0.0 {
angle += 360.0;
}
while angle >= 360.0 {
angle -= 360.0;
}
angle
};
start_angle = normalize(start_angle);
end_angle = normalize(end_angle);
let ccw_sweep = (end_angle - start_angle).rem_euclid(360.0);
let cw_sweep = (start_angle - end_angle).rem_euclid(360.0);
@ -307,8 +305,6 @@ impl Arc {
return Err("Arc sweep too small".into());
}
let start_angle = qet_start_angle(start_angle);
Ok(Arc {
x: center_x - radius,
y: center_y_qet - radius,

Loading…
Cancel
Save