Skip to content

Commit 59502ac

Browse files
committed
camelCase!
1 parent 4c5c01d commit 59502ac

28 files changed

Lines changed: 701 additions & 731 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Note Clipper2’s core algorithms operate on **integer coordinates** for numeric
3535
```java
3636
Paths64 subj = new Paths64();
3737
Paths64 clip = new Paths64();
38-
subj.add(Clipper.MakePath(new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 }));
39-
clip.add(Clipper.MakePath(new int[] { 98, 63, 4, 68, 77, 8, 52, 100, 19, 12 }));
40-
Paths64 solution = Clipper.Union(subj, clip, FillRule.NonZero);
38+
subj.add(Clipper.makePath(new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 }));
39+
clip.add(Clipper.makePath(new int[] { 98, 63, 4, 68, 77, 8, 52, 100, 19, 12 }));
40+
Paths64 solution = Clipper.union(subj, clip, FillRule.NonZero);
4141
solution.get(0).forEach(p -> System.out.println(p.toString()));
4242
```
4343

src/main/java/com/github/micycle1/clipper2/Clipper.java

Lines changed: 276 additions & 276 deletions
Large diffs are not rendered by default.

src/main/java/com/github/micycle1/clipper2/Minkowski.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,35 @@ public final class Minkowski {
1212
private Minkowski() {
1313
}
1414

15-
public static Paths64 Sum(Path64 pattern, Path64 path, boolean isClosed) {
16-
return Clipper.Union(MinkowskiInternal(pattern, path, true, isClosed), FillRule.NonZero);
15+
public static Paths64 sum(Path64 pattern, Path64 path, boolean isClosed) {
16+
return Clipper.union(MinkowskiInternal(pattern, path, true, isClosed), FillRule.NonZero);
1717
}
1818

19-
public static PathsD Sum(PathD pattern, PathD path, boolean isClosed) {
20-
return Sum(pattern, path, isClosed, 2);
19+
public static PathsD sum(PathD pattern, PathD path, boolean isClosed) {
20+
return sum(pattern, path, isClosed, 2);
2121
}
2222

23-
public static PathsD Sum(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) {
23+
public static PathsD sum(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) {
2424
double scale = Math.pow(10, decimalPlaces);
25-
Paths64 tmp = Clipper.Union(
26-
MinkowskiInternal(Clipper.ScalePath64(pattern, scale), Clipper.ScalePath64(path, scale), true, isClosed), FillRule.NonZero);
27-
return Clipper.ScalePathsD(tmp, 1 / scale);
25+
Paths64 tmp = Clipper.union(
26+
MinkowskiInternal(Clipper.scalePath64(pattern, scale), Clipper.scalePath64(path, scale), true, isClosed), FillRule.NonZero);
27+
return Clipper.scalePathsD(tmp, 1 / scale);
2828
}
2929

30-
public static Paths64 Diff(Path64 pattern, Path64 path, boolean isClosed) {
31-
return Clipper.Union(MinkowskiInternal(pattern, path, false, isClosed), FillRule.NonZero);
30+
public static Paths64 diff(Path64 pattern, Path64 path, boolean isClosed) {
31+
return Clipper.union(MinkowskiInternal(pattern, path, false, isClosed), FillRule.NonZero);
3232
}
3333

34-
public static PathsD Diff(PathD pattern, PathD path, boolean isClosed) {
35-
return Diff(pattern, path, isClosed, 2);
34+
public static PathsD diff(PathD pattern, PathD path, boolean isClosed) {
35+
return diff(pattern, path, isClosed, 2);
3636
}
3737

38-
public static PathsD Diff(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) {
38+
public static PathsD diff(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) {
3939
double scale = Math.pow(10, decimalPlaces);
40-
Paths64 tmp = Clipper.Union(
41-
MinkowskiInternal(Clipper.ScalePath64(pattern, scale), Clipper.ScalePath64(path, scale), false, isClosed),
40+
Paths64 tmp = Clipper.union(
41+
MinkowskiInternal(Clipper.scalePath64(pattern, scale), Clipper.scalePath64(path, scale), false, isClosed),
4242
FillRule.NonZero);
43-
return Clipper.ScalePathsD(tmp, 1 / scale);
43+
return Clipper.scalePathsD(tmp, 1 / scale);
4444
}
4545

4646
private static Paths64 MinkowskiInternal(Path64 pattern, Path64 path, boolean isSum, boolean isClosed) {
@@ -69,8 +69,8 @@ private static Paths64 MinkowskiInternal(Path64 pattern, Path64 path, boolean is
6969
for (int i = delta; i < pathLen; i++) {
7070
for (int j = 0; j < patLen; j++) {
7171
Path64 quad = new Path64(tmp.get(g).get(h), tmp.get(i).get(h), tmp.get(i).get(j), tmp.get(g).get(j));
72-
if (!Clipper.IsPositive(quad)) {
73-
result.add(Clipper.ReversePath(quad));
72+
if (!Clipper.isPositive(quad)) {
73+
result.add(Clipper.reversePath(quad));
7474
} else {
7575
result.add(quad);
7676
}

src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public final class InternalClipper {
1313

1414
private static final String PRECISION_RANGE_ERROR = "Error: Precision is out of range.";
1515

16-
public static void CheckPrecision(int precision) {
16+
public static void checkPrecision(int precision) {
1717
if (precision < -8 || precision > 8) {
1818
throw new IllegalArgumentException(PRECISION_RANGE_ERROR);
1919
}
@@ -22,16 +22,16 @@ public static void CheckPrecision(int precision) {
2222
private InternalClipper() {
2323
}
2424

25-
public static boolean IsAlmostZero(double value) {
25+
public static boolean isAlmostZero(double value) {
2626
return (Math.abs(value) <= FLOATING_POINT_TOLERANCE);
2727
}
2828

29-
public static double CrossProduct(Point64 pt1, Point64 pt2, Point64 pt3) {
29+
public static double crossProduct(Point64 pt1, Point64 pt2, Point64 pt3) {
3030
// typecast to double to avoid potential int overflow
3131
return ((double) (pt2.x - pt1.x) * (pt3.y - pt2.y) - (double) (pt2.y - pt1.y) * (pt3.x - pt2.x));
3232
}
3333

34-
public static int CrossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) {
34+
public static int crossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) {
3535
long a = pt2.x - pt1.x;
3636
long b = pt3.y - pt2.y;
3737
long c = pt2.y - pt1.y;
@@ -56,27 +56,27 @@ public static int CrossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) {
5656
return signAB > signCD ? 1 : -1;
5757
}
5858

59-
public static double DotProduct(Point64 pt1, Point64 pt2, Point64 pt3) {
59+
public static double dotProduct(Point64 pt1, Point64 pt2, Point64 pt3) {
6060
// typecast to double to avoid potential int overflow
6161
return ((double) (pt2.x - pt1.x) * (pt3.x - pt2.x) + (double) (pt2.y - pt1.y) * (pt3.y - pt2.y));
6262
}
6363

64-
public static double CrossProduct(PointD vec1, PointD vec2) {
64+
public static double crossProduct(PointD vec1, PointD vec2) {
6565
return (vec1.y * vec2.x - vec2.y * vec1.x);
6666
}
6767

68-
public static double DotProduct(PointD vec1, PointD vec2) {
68+
public static double dotProduct(PointD vec1, PointD vec2) {
6969
return (vec1.x * vec2.x + vec1.y * vec2.y);
7070
}
7171

72-
public static long CheckCastInt64(double val) {
72+
public static long checkCastInt64(double val) {
7373
if ((val >= MAX_COORD) || (val <= MIN_COORD)) {
7474
return Invalid64;
7575
}
7676
return (long) Math.rint(val);
7777
}
7878

79-
public static boolean GetLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
79+
public static boolean getLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
8080
double dy1 = (ln1b.y - ln1a.y);
8181
double dx1 = (ln1b.x - ln1a.x);
8282
double dy2 = (ln2b.y - ln2a.y);
@@ -110,7 +110,7 @@ public static boolean GetLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2
110110
return true;
111111
}
112112

113-
public static boolean GetLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, PointD ln2b, /* out */ PointD ip) {
113+
public static boolean getLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, PointD ln2b, /* out */ PointD ip) {
114114
double dy1 = (ln1b.y - ln1a.y);
115115
double dx1 = (ln1b.x - ln1a.x);
116116
double dy2 = (ln2b.y - ln2a.y);
@@ -137,38 +137,38 @@ public static boolean GetLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a,
137137
return true;
138138
}
139139

140-
public static boolean GetSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
141-
return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip);
140+
public static boolean getSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
141+
return getLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip);
142142
}
143143

144144
@Deprecated
145-
public static boolean GetIntersectPoint(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
146-
return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip);
145+
public static boolean getIntersectPoint(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) {
146+
return getLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip);
147147
}
148148

149-
public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b) {
150-
return SegsIntersect(seg1a, seg1b, seg2a, seg2b, false);
149+
public static boolean segsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b) {
150+
return segsIntersect(seg1a, seg1b, seg2a, seg2b, false);
151151
}
152152

153-
public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b, boolean inclusive) {
153+
public static boolean segsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b, boolean inclusive) {
154154
if (inclusive) {
155-
double res1 = CrossProduct(seg1a, seg2a, seg2b);
156-
double res2 = CrossProduct(seg1b, seg2a, seg2b);
155+
double res1 = crossProduct(seg1a, seg2a, seg2b);
156+
double res2 = crossProduct(seg1b, seg2a, seg2b);
157157
if (res1 * res2 > 0) {
158158
return false;
159159
}
160-
double res3 = CrossProduct(seg2a, seg1a, seg1b);
161-
double res4 = CrossProduct(seg2b, seg1a, seg1b);
160+
double res3 = crossProduct(seg2a, seg1a, seg1b);
161+
double res4 = crossProduct(seg2b, seg1a, seg1b);
162162
if (res3 * res4 > 0) {
163163
return false;
164164
}
165165
return (res1 != 0 || res2 != 0 || res3 != 0 || res4 != 0);
166166
}
167-
return (CrossProduct(seg1a, seg2a, seg2b) * CrossProduct(seg1b, seg2a, seg2b) < 0)
168-
&& (CrossProduct(seg2a, seg1a, seg1b) * CrossProduct(seg2b, seg1a, seg1b) < 0);
167+
return (crossProduct(seg1a, seg2a, seg2b) * crossProduct(seg1b, seg2a, seg2b) < 0)
168+
&& (crossProduct(seg2a, seg1a, seg1b) * crossProduct(seg2b, seg1a, seg1b) < 0);
169169
}
170170

171-
public static Point64 GetClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 seg2) {
171+
public static Point64 getClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 seg2) {
172172
if (seg1.x == seg2.x && seg1.y == seg2.y) {
173173
return seg1;
174174
}
@@ -183,7 +183,7 @@ public static Point64 GetClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64
183183
return new Point64(seg1.x + Math.rint(q * dx), seg1.y + Math.rint(q * dy));
184184
}
185185

186-
public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) {
186+
public static PointInPolygonResult pointInPolygon(Point64 pt, Path64 polygon) {
187187
int len = polygon.size(), start = 0;
188188
if (len < 3) {
189189
return PointInPolygonResult.IsOutside;
@@ -246,7 +246,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) {
246246
} else if (pt.x > prev.x && pt.x > curr.x) {
247247
val = 1 - val; // toggle val
248248
} else {
249-
int cps = CrossProductSign(prev, curr, pt);
249+
int cps = crossProductSign(prev, curr, pt);
250250
if (cps == 0) {
251251
return PointInPolygonResult.IsOn;
252252
}
@@ -262,7 +262,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) {
262262
if (i == len) {
263263
i = 0;
264264
}
265-
int cps = (i == 0) ? CrossProductSign(polygon.get(len - 1), polygon.get(0), pt) : CrossProductSign(polygon.get(i - 1), polygon.get(i), pt);
265+
int cps = (i == 0) ? crossProductSign(polygon.get(len - 1), polygon.get(0), pt) : crossProductSign(polygon.get(i - 1), polygon.get(i), pt);
266266
if (cps == 0) {
267267
return PointInPolygonResult.IsOn;
268268
}
@@ -280,7 +280,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) {
280280
/**
281281
* Given three points, returns true if they are collinear.
282282
*/
283-
public static boolean IsCollinear(Point64 pt1, Point64 sharedPt, Point64 pt2) {
283+
public static boolean isCollinear(Point64 pt1, Point64 sharedPt, Point64 pt2) {
284284
long a = sharedPt.x - pt1.x;
285285
long b = pt2.y - sharedPt.y;
286286
long c = sharedPt.y - pt1.y;
@@ -348,7 +348,7 @@ private static int triSign(long x) {
348348
return x < 0 ? -1 : (x > 0 ? 1 : 0);
349349
}
350350

351-
public static Rect64 GetBounds(Path64 path) {
351+
public static Rect64 getBounds(Path64 path) {
352352
if (path.isEmpty()) {
353353
return new Rect64();
354354
}
@@ -370,11 +370,11 @@ public static Rect64 GetBounds(Path64 path) {
370370
return result;
371371
}
372372

373-
public static boolean Path2ContainsPath1(Path64 path1, Path64 path2) {
373+
public static boolean path2ContainsPath1(Path64 path1, Path64 path2) {
374374
// accommodate potential rounding error before deciding either way
375375
PointInPolygonResult pip = PointInPolygonResult.IsOn;
376376
for (Point64 pt : path1) {
377-
switch (PointInPolygon(pt, path2)) {
377+
switch (pointInPolygon(pt, path2)) {
378378
case IsOutside:
379379
if (pip == PointInPolygonResult.IsOutside) {
380380
return false;
@@ -392,8 +392,8 @@ public static boolean Path2ContainsPath1(Path64 path1, Path64 path2) {
392392
}
393393
}
394394
// path1 is still equivocal, so test its midpoint
395-
Point64 mp = GetBounds(path1).MidPoint();
396-
return PointInPolygon(mp, path2) != PointInPolygonResult.IsOutside;
395+
Point64 mp = getBounds(path1).midPoint();
396+
return pointInPolygon(mp, path2) != PointInPolygonResult.IsOutside;
397397
}
398398

399399
}

src/main/java/com/github/micycle1/clipper2/core/PointD.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public PointD(double x, double y) {
4242
this.y = y;
4343
}
4444

45-
public void Negate() {
45+
public void negate() {
4646
x = -x;
4747
y = -y;
4848
}
@@ -53,11 +53,11 @@ public final String toString() {
5353
}
5454

5555
public static boolean opEquals(PointD lhs, PointD rhs) {
56-
return InternalClipper.IsAlmostZero(lhs.x - rhs.x) && InternalClipper.IsAlmostZero(lhs.y - rhs.y);
56+
return InternalClipper.isAlmostZero(lhs.x - rhs.x) && InternalClipper.isAlmostZero(lhs.y - rhs.y);
5757
}
5858

5959
public static boolean opNotEquals(PointD lhs, PointD rhs) {
60-
return !InternalClipper.IsAlmostZero(lhs.x - rhs.x) || !InternalClipper.IsAlmostZero(lhs.y - rhs.y);
60+
return !InternalClipper.isAlmostZero(lhs.x - rhs.x) || !InternalClipper.isAlmostZero(lhs.y - rhs.y);
6161
}
6262

6363
@Override

src/main/java/com/github/micycle1/clipper2/core/Rect64.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void setHeight(long value) {
5858
bottom = top + value;
5959
}
6060

61-
public Path64 AsPath() {
61+
public Path64 asPath() {
6262
Path64 result = new Path64(4);
6363
result.add(new Point64(left, top));
6464
result.add(new Point64(right, top));
@@ -67,35 +67,35 @@ public Path64 AsPath() {
6767
return result;
6868
}
6969

70-
public boolean IsEmpty() {
70+
public boolean isEmpty() {
7171
return bottom <= top || right <= left;
7272
}
7373

74-
public boolean IsValid() {
74+
public boolean isValid() {
7575
return left < Long.MAX_VALUE;
7676
}
7777

78-
public Point64 MidPoint() {
78+
public Point64 midPoint() {
7979
return new Point64((left + right) / 2, (top + bottom) / 2);
8080
}
8181

82-
public boolean Contains(Point64 pt) {
82+
public boolean contains(Point64 pt) {
8383
return pt.x > left && pt.x < right && pt.y > top && pt.y < bottom;
8484
}
8585

86-
public boolean Intersects(Rect64 rec) {
86+
public boolean intersects(Rect64 rec) {
8787
return (Math.max(left, rec.left) <= Math.min(right, rec.right)) && (Math.max(top, rec.top) <= Math.min(bottom, rec.bottom));
8888
}
8989

90-
public boolean Contains(Rect64 rec) {
90+
public boolean contains(Rect64 rec) {
9191
return rec.left >= left && rec.right <= right && rec.top >= top && rec.bottom <= bottom;
9292
}
9393

9494
public static Rect64 opAdd(Rect64 lhs, Rect64 rhs) {
95-
if (!lhs.IsValid()) {
95+
if (!lhs.isValid()) {
9696
return rhs.clone();
9797
}
98-
if (!rhs.IsValid()) {
98+
if (!rhs.isValid()) {
9999
return lhs.clone();
100100
}
101101
return new Rect64(Math.min(lhs.left, rhs.left), Math.min(lhs.top, rhs.top), Math.max(lhs.right, rhs.right),

src/main/java/com/github/micycle1/clipper2/core/RectD.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ public void setHeight(double value) {
6060
bottom = top + value;
6161
}
6262

63-
public boolean IsEmpty() {
63+
public boolean isEmpty() {
6464
return bottom <= top || right <= left;
6565
}
6666

67-
public PointD MidPoint() {
67+
public PointD midPoint() {
6868
return new PointD((left + right) / 2, (top + bottom) / 2);
6969
}
7070

71-
public boolean Contains(PointD pt) {
71+
public boolean contains(PointD pt) {
7272
return pt.x > left && pt.x < right && pt.y > top && pt.y < bottom;
7373
}
7474

75-
public boolean Contains(RectD rec) {
75+
public boolean contains(RectD rec) {
7676
return rec.left >= left && rec.right <= right && rec.top >= top && rec.bottom <= bottom;
7777
}
7878

79-
public boolean Intersects(RectD rec) {
79+
public boolean intersects(RectD rec) {
8080
return (Math.max(left, rec.left) < Math.min(right, rec.right)) && (Math.max(top, rec.top) < Math.min(bottom, rec.bottom));
8181
}
8282

83-
public PathD AsPath() {
83+
public PathD asPath() {
8484
PathD result = new PathD(
8585
Arrays.asList(new PointD(left, top), new PointD(right, top), new PointD(right, bottom), new PointD(left, bottom)));
8686
return result;

0 commit comments

Comments
 (0)