@@ -5,12 +5,14 @@ import type { IShape } from "@thi.ng/geom-api";
5
5
import {
6
6
classifyPointInCircle ,
7
7
classifyPointInTriangle2 ,
8
+ classifyPointSegment2 ,
8
9
} from "@thi.ng/geom-isec/point" ;
9
10
import { sign } from "@thi.ng/math/abs" ;
10
11
import { EPS } from "@thi.ng/math/api" ;
11
12
import type { ReadonlyVec } from "@thi.ng/vectors" ;
12
13
import { dot } from "@thi.ng/vectors/dot" ;
13
14
import type { Circle } from "./api/circle.js" ;
15
+ import type { Line } from "./api/line.js" ;
14
16
import type { Plane } from "./api/plane.js" ;
15
17
import type { Triangle } from "./api/triangle.js" ;
16
18
import { __dispatch } from "./internal/dispatch.js" ;
@@ -24,6 +26,7 @@ import { __dispatch } from "./internal/dispatch.js";
24
26
* Currently only implemented for:
25
27
*
26
28
* - {@link Circle}
29
+ * - {@link Line} (-1 = right/clockwise, +1 = left/counterclockwise)
27
30
* - {@link Plane} (-1 = below, +1 = above)
28
31
* - {@link Sphere}
29
32
* - {@link Triangle}
@@ -49,7 +52,11 @@ export const classifyPoint: MultiFn2O<IShape, ReadonlyVec, number, number> =
49
52
circle : ( $ : Circle , p , eps = EPS ) =>
50
53
classifyPointInCircle ( p , $ . pos , $ . r , eps ) ,
51
54
52
- plane : ( $ : Plane , p , eps ) => sign ( dot ( $ . normal , p ) - $ . w , eps ) ,
55
+ line : ( { points : [ a , b ] } : Line , p , eps = EPS ) =>
56
+ classifyPointSegment2 ( p , a , b , eps ) ,
57
+
58
+ plane : ( $ : Plane , p , eps = EPS ) =>
59
+ sign ( dot ( $ . normal , p ) - $ . w , eps ) ,
53
60
54
61
tri : ( { points } : Triangle , p : ReadonlyVec , eps = EPS ) =>
55
62
classifyPointInTriangle2 (
0 commit comments