1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// SPDX-License-Identifier: MIT
//
// Copyright (c) 2025 Alexandre Severino
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
use Ordering;
use ;
// #[test]
// fn test_coplanar_overlap()
// //where
// // Point3<f64>: From<Vector3<f64>>,
// {
// // Two right triangles in the z=0 plane sharing the diagonal from (0,1) to (1,0)
// let t1 = [
// Point3::<CgarF64>::from_vals([0.0, 0.0, 0.0]),
// Point3::from_vals([1.0, 0.0, 0.0]),
// Point3::from_vals([0.0, 1.0, 0.0]),
// ];
// let t2 = [
// Point3::from_vals([0.0, 1.0, 0.0]),
// Point3::from_vals([1.0, 0.0, 0.0]),
// Point3::from_vals([1.0, 1.0, 0.0]),
// ];
// let seg = tri_tri_intersection(&t1, &t2).expect("triangles should intersect");
// // We expect the endpoints (0,1,0) and (1,0,0), in either order.
// let (a, b) = (
// (seg.a[0].clone(), seg.a[1].clone(), seg.a[2].clone()),
// (seg.b[0].clone(), seg.b[1].clone(), seg.b[2].clone()),
// );
// let wanted = [
// (CgarF64(0.0), CgarF64(1.0), CgarF64(0.0)),
// (1.0.into(), 0.0.into(), 0.0.into()),
// ];
// let mut actual = [a, b];
// actual.sort_by(|p, q| p.partial_cmp(q).unwrap_or(Ordering::Equal));
// let mut expected = wanted;
// expected.sort_by(|p, q| p.partial_cmp(q).unwrap_or(Ordering::Equal));
// assert_eq!(actual, expected);
// }
// #[test]
// fn test_coplanar_disjoint() {
// // Two triangles in the z=0 plane that do not touch
// let t1 = [
// Point3::<CgarF64>::from_vals([0.0, 0.0, 0.0]),
// Point3::from_vals([1.0, 0.0, 0.0]),
// Point3::from_vals([0.0, 1.0, 0.0]),
// ];
// let t2 = [
// Point3::from_vals([2.0, 2.0, 0.0]),
// Point3::from_vals([3.0, 2.0, 0.0]),
// Point3::from_vals([2.0, 3.0, 0.0]),
// ];
// let seg = tri_tri_intersection(&t1, &t2);
// assert!(
// seg.is_none(),
// "disjoint coplanar triangles should not intersect"
// );
// }
// #[test]
// fn test_non_coplanar_slice_f64() {
// // A horizontal triangle in z=0
// let t1 = [
// Point3::<CgarF64>::from_vals([0.0, 0.0, 0.0]),
// Point3::from_vals([1.0, 0.0, 0.0]),
// Point3::from_vals([0.0, 1.0, 0.0]),
// ];
// // A vertical triangle that slices through t1, intersecting along a segment
// let t2 = [
// Point3::from_vals([0.2, 0.2, -1.0]),
// Point3::from_vals([0.2, 0.2, 1.0]),
// Point3::from_vals([0.8, 0.8, 1.0]),
// ];
// let seg = tri_tri_intersection(&t1, &t2).expect("should slice and intersect");
// // The two intersection points should lie on z=0 at (0.2,0.2) and (0.5,0.5)
// let (a2, b2) = (
// (seg.a[0].clone(), seg.a[1].clone()),
// (seg.b[0].clone(), seg.b[1].clone()),
// );
// let pts = [a2, b2];
// println!("Intersection points: {:?}", pts);
// assert!(pts.contains(&(0.2.into(), 0.2.into())));
// assert!(pts.contains(&(0.5.into(), 0.5.into())));
// }