17 template <
typename Real>
35 template <
typename Real>
59 Real segment0Parameter[2], segment1Parameter[2];
68 template <
typename Real>
74 Vector2<Real> seg0Origin, seg0Direction, seg1Origin, seg1Direction;
75 Real seg0Extent, seg1Extent;
76 segment0.GetCenteredForm(seg0Origin, seg0Direction, seg0Extent);
77 segment1.GetCenteredForm(seg1Origin, seg1Direction, seg1Extent);
82 auto llResult = llQuery(line0, line1);
83 if (llResult.numIntersections == 1)
86 if (
std::abs(llResult.line0Parameter[0]) <= seg0Extent
87 &&
std::abs(llResult.line1Parameter[0]) <= seg1Extent)
89 result.intersect =
true;
90 result.numIntersections = 1;
94 result.intersect =
false;
95 result.numIntersections = 0;
98 else if (llResult.numIntersections == std::numeric_limits<int>::max())
102 Real
t =
Dot(seg0Direction, diff);
105 std::array<Real, 2> interval0 = { -seg0Extent, seg0Extent };
106 std::array<Real, 2> interval1 = { t - seg1Extent, t + seg1Extent };
110 auto iiResult = iiQuery(interval0, interval1);
111 result.intersect =
true;
112 result.numIntersections = iiResult.numIntersections;
116 result.intersect =
false;
117 result.numIntersections = 0;
123 template <
typename Real>
129 Vector2<Real> seg0Origin, seg0Direction, seg1Origin, seg1Direction;
130 Real seg0Extent, seg1Extent;
131 segment0.GetCenteredForm(seg0Origin, seg0Direction, seg0Extent);
132 segment1.GetCenteredForm(seg1Origin, seg1Direction, seg1Extent);
137 auto llResult = llQuery(line0, line1);
138 if (llResult.numIntersections == 1)
141 if (
std::abs(llResult.line0Parameter[0]) <= seg0Extent
142 &&
std::abs(llResult.line1Parameter[0]) <= seg1Extent)
144 result.intersect =
true;
145 result.numIntersections = 1;
146 result.segment0Parameter[0] = llResult.line0Parameter[0];
147 result.segment1Parameter[0] = llResult.line1Parameter[0];
148 result.point[0] = llResult.point;
152 result.intersect =
false;
153 result.numIntersections = 0;
156 else if (llResult.numIntersections == std::numeric_limits<int>::max())
160 Real
t =
Dot(seg0Direction, diff);
163 std::array<Real, 2> interval0 = { -seg0Extent, seg0Extent };
164 std::array<Real, 2> interval1 = { t - seg1Extent, t + seg1Extent };
168 auto iiResult = iiQuery(interval0, interval1);
169 if (iiResult.intersect)
171 result.intersect =
true;
172 result.numIntersections = iiResult.numIntersections;
173 for (
int i = 0; i < iiResult.numIntersections; ++i)
175 result.segment0Parameter[i] = iiResult.overlap[i];
176 result.segment1Parameter[i] = iiResult.overlap[i] -
t;
177 result.point[i] = seg0Origin +
178 result.segment0Parameter[i] * seg0Direction;
183 result.intersect =
false;
184 result.numIntersections = 0;
189 result.intersect =
false;
190 result.numIntersections = 0;
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)