mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
No need to wrap angles as they're always -PI < a < PI.
This commit is contained in:
parent
2026e5571e
commit
197aa4b4cf
1 changed files with 4 additions and 9 deletions
|
@ -328,11 +328,6 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
console.log(c1.getValues(), c2.getValues(), c3.getValues(), c4.getValues());
|
console.log(c1.getValues(), c2.getValues(), c3.getValues(), c4.getValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAngle(tangent) {
|
|
||||||
var a = tangent.getAngleInRadians();
|
|
||||||
return a < -PI ? a + PI_2 : a >= PI ? a - PI_2 : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isInRange(angle, min, max) {
|
function isInRange(angle, min, max) {
|
||||||
return min < max
|
return min < max
|
||||||
? angle > min && angle < max
|
? angle > min && angle < max
|
||||||
|
@ -341,10 +336,10 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate angles for all four tangents at the intersection point
|
// Calculate angles for all four tangents at the intersection point
|
||||||
var a1 = getAngle(c1.getTangentAt(tMax, true).negate()),
|
var a1 = c1.getTangentAt(tMax, true).negate().getAngleInRadians(),
|
||||||
a2 = getAngle(c2.getTangentAt(tMin, true)),
|
a2 = c2.getTangentAt(tMin, true).getAngleInRadians(),
|
||||||
a3 = getAngle(c3.getTangentAt(tMax, true).negate()),
|
a3 = c3.getTangentAt(tMax, true).negate().getAngleInRadians(),
|
||||||
a4 = getAngle(c4.getTangentAt(tMin, true));
|
a4 = c4.getTangentAt(tMin, true).getAngleInRadians();
|
||||||
|
|
||||||
// Count how many times curve2 angles appear between the curve1 angles
|
// Count how many times curve2 angles appear between the curve1 angles
|
||||||
// If each pair of angles split the other two, then the edges cross.
|
// If each pair of angles split the other two, then the edges cross.
|
||||||
|
|
Loading…
Reference in a new issue