Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #1589

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Cleanup #1589

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions crates/geometry/src/line_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,18 @@ impl<Frame> LineSegment<Frame> {
return false;
}

let projection = (arc.circle.center - self.0).dot(&(self.1 - self.0));
let projected_point_relative_contribution = projection / self.length_squared();
let base_point = self.0 + (self.1 - self.0) * projected_point_relative_contribution;
let direction = self.1 - self.0;
let normed_direction = direction.normalize();

let projection = (arc.circle.center - self.0).dot(&normed_direction);
let base_point = self.0 + normed_direction * projection;

let center_to_base_length = (base_point - arc.circle.center).norm();
let base_to_intersection_length =
f32::sqrt(arc.circle.radius.powi(2) - center_to_base_length.powi(2));

let direction_vector = vector![self.1.x() - self.0.x(), self.1.y() - self.0.y()];
let normed_direction_vector = direction_vector.normalize();

let intersection_point1 =
base_point + normed_direction_vector * base_to_intersection_length;
let intersection_point2 =
base_point - normed_direction_vector * base_to_intersection_length;
let intersection_point1 = base_point + normed_direction * base_to_intersection_length;
let intersection_point2 = base_point - normed_direction * base_to_intersection_length;

let mut intersection_points: Vec<_> = Vec::new();
if (0.0..1.0).contains(&self.projection_factor(intersection_point1)) {
Expand Down
Loading