Skip to content

Commit

Permalink
adjustment allowing tests to pass. There was a back and forth with mb…
Browse files Browse the repository at this point in the history
…utterick in GitHub issue 81 about what value is best. Appears that 1.0e-13 or 1.0e-14 are both good values to use.
  • Loading branch information
hfutrell committed Jan 21, 2021
1 parent f507be2 commit b57bff8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions BezierKit/Library/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ internal class Utils {
let q = (2 * a * a * a - 9 * a * b + 27 * c) / 27
let q2 = q/2
let discriminant = q2 * q2 + p * p * p / 27
if discriminant < -smallValue {
let tinyValue = 1.0e-14
if discriminant < -tinyValue {
let r = sqrt(-p * p * p / 27)
let t = -q / (2 * r)
let cosphi = t < -1 ? -1 : t > 1 ? 1 : t
Expand All @@ -204,7 +205,7 @@ internal class Utils {
if root3 > root2 {
callback(root3)
}
} else if discriminant > smallValue {
} else if discriminant > tinyValue {
let sd = sqrt(discriminant)
let u1 = crt(-q2 + sd)
let v1 = crt(q2 + sd)
Expand Down

0 comments on commit b57bff8

Please sign in to comment.