areaPen.py: invert sign of area (CCW is now positive)

This commit is contained in:
Cosimo Lupo 2016-06-12 03:12:02 +01:00
parent c08e47ed47
commit 38359b054d

View File

@ -10,7 +10,7 @@ def interpolate(p0, p1, t):
def polygon_area(p0, p1):
return (p1[0] - p0[0]) * (p1[1] + p0[1]) * 0.5
return -(p1[0] - p0[0]) * (p1[1] + p0[1]) * 0.5
def quadratic_curve_area(p0, p1, p2):
@ -24,7 +24,7 @@ def cubic_curve_area(p0, p1, p2, p3):
x1, y1 = p1[0] - x0, p1[1] - y0
x2, y2 = p2[0] - x0, p2[1] - y0
x3, y3 = p3[0] - x0, p3[1] - y0
return (
return -(
x1 * ( - y2 - y3) +
x2 * (y1 - 2*y3) +
x3 * (y1 + 2*y2 )