mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 06:18:11 +08:00
Divide the large Bezier-rs implementation file into smaller ones (#751)
* Refactor bezier lib file into a separate folder * Add better implementation comments * Update import of Subpath from bezier-rs * Add comment to describe compare.rs * Remove printlns and adjust spacing
This commit is contained in:
@@ -58,16 +58,14 @@ pub fn solve_linear(a: f64, b: f64) -> Vec<f64> {
|
||||
/// Precompute the `discriminant` (`b^2 - 4ac`) and `two_times_a` arguments prior to calling this function for efficiency purposes.
|
||||
pub fn solve_quadratic(discriminant: f64, two_times_a: f64, b: f64, c: f64) -> Vec<f64> {
|
||||
let mut roots = Vec::new();
|
||||
if two_times_a != 0. {
|
||||
if discriminant > 0. {
|
||||
let root_discriminant = discriminant.sqrt();
|
||||
roots.push((-b + root_discriminant) / (two_times_a));
|
||||
roots.push((-b - root_discriminant) / (two_times_a));
|
||||
} else if discriminant == 0. {
|
||||
roots.push(-b / (two_times_a));
|
||||
}
|
||||
} else {
|
||||
if two_times_a.abs() <= STRICT_MAX_ABSOLUTE_DIFFERENCE {
|
||||
roots = solve_linear(b, c);
|
||||
} else if discriminant.abs() <= STRICT_MAX_ABSOLUTE_DIFFERENCE {
|
||||
roots.push(-b / (two_times_a));
|
||||
} else if discriminant > 0. {
|
||||
let root_discriminant = discriminant.sqrt();
|
||||
roots.push((-b + root_discriminant) / (two_times_a));
|
||||
roots.push((-b - root_discriminant) / (two_times_a));
|
||||
}
|
||||
roots
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user