@@ -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}
0 commit comments