Skip to content

Commit 618c05c

Browse files
committed
clipper.core.h - updated documentation and minor bugfix
1 parent 879e2e8 commit 618c05c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CPP/Clipper2Lib/include/clipper2/clipper.core.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 11 October 2025 *
3+
* Date : 12 October 2025 *
44
* Website : https://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2025 *
66
* Purpose : Core Clipper Library structures and functions *
@@ -884,14 +884,18 @@ namespace Clipper2Lib
884884
return Area<T>(poly) >= 0;
885885
}
886886

887+
// GetLineIntersectPt - a 'true' result is non-parallel. The 'ip' will also
888+
// be constrained to seg1. However, it's possible that 'ip' won't be inside
889+
// seg2, even when 'ip' hasn't been constrained (ie 'ip' is inside seg1).
890+
887891
#if CLIPPER2_HI_PRECISION
888892
// caution: this will compromise performance
889893
// https://github.com/AngusJohnson/Clipper2/issues/317#issuecomment-1314023253
890894
// See also CPP/BenchMark/GetIntersectPtBenchmark.cpp
891895
#define CC_MIN(x,y) ((x)>(y)?(y):(x))
892896
#define CC_MAX(x,y) ((x)<(y)?(y):(x))
893897
template<typename T>
894-
inline bool GetSegmentIntersectPt(const Point<T>& ln1a, const Point<T>& ln1b,
898+
inline bool GetLineIntersectPt(const Point<T>& ln1a, const Point<T>& ln1b,
895899
const Point<T>& ln2a, const Point<T>& ln2b, Point<T>& ip)
896900
{
897901
double ln1dy = static_cast<double>(ln1b.y - ln1a.y);
@@ -937,6 +941,9 @@ namespace Clipper2Lib
937941
ip.x = originx + static_cast<T>(hitx);
938942
ip.y = originy + static_cast<T>(hity);
939943
}
944+
#ifdef USINGZ
945+
ip.z = 0;
946+
#endif
940947
return true;
941948
}
942949
#else
@@ -959,7 +966,10 @@ namespace Clipper2Lib
959966
{
960967
ip.x = static_cast<T>(ln1a.x + t * dx1);
961968
ip.y = static_cast<T>(ln1a.y + t * dy1);
962-
}
969+
#ifdef USINGZ
970+
ip.z = 0;
971+
#endif
972+
}
963973
return true;
964974
}
965975
#endif

CSharp/Clipper2Lib/Clipper.Core.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 11 October 2025 *
3+
* Date : 12 October 2025 *
44
* Website : https://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2025 *
66
* Purpose : Core structures and functions for the Clipper Library *
@@ -669,6 +669,9 @@ internal static long CheckCastInt64(double val)
669669
return (long)Math.Round(val, MidpointRounding.AwayFromZero);
670670
}
671671

672+
// GetLineIntersectPt - a 'true' result is non-parallel. The 'ip' will also
673+
// be constrained to seg1. However, it's possible that 'ip' won't be inside
674+
// seg2, even when 'ip' hasn't been constrained (ie 'ip' is inside seg1).
672675

673676
[MethodImpl(MethodImplOptions.AggressiveInlining)]
674677
public static bool GetLineIntersectPt(Point64 ln1a,

Delphi/Clipper2Lib/Clipper.Core.pas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
(*******************************************************************************
44
* Author : Angus Johnson *
5-
* Date : 11 October 2025 *
5+
* Date : 12 October 2025 *
66
* Website : https://www.angusj.com *
77
* Copyright : Angus Johnson 2010-2024 *
88
* Purpose : Core Clipper Library module *
@@ -334,6 +334,9 @@ procedure AppendPaths(var paths: TPathsD; const extra: TPathsD); overload;
334334

335335
function ArrayOfPathsToPaths(const ap: TArrayOfPaths): TPaths64;
336336

337+
// GetLineIntersectPt - a 'true' result is non-parallel. The 'ip' will also
338+
// be constrained to seg1. However, it's possible that 'ip' won't be inside
339+
// seg2, even when 'ip' hasn't been constrained (ie 'ip' is inside seg1).
337340
function GetLineIntersectPt(const ln1a, ln1b, ln2a, ln2b: TPoint64;
338341
out ip: TPoint64): Boolean; overload;
339342
function GetLineIntersectPt(const ln1a, ln1b, ln2a, ln2b: TPointD;

0 commit comments

Comments
 (0)