135 alpha = 2 *
M_PI - alpha;
138 double dx = bchk.
nSigmas * sqrt(bchk.lCovariance(0, 0));
140 bchk.
nSigmas * sqrt(scResult.
sinC * scResult.
sinC * bchk.lCovariance(0, 0) +
141 locpo(0, 0) * locpo(0, 0) * scResult.
cosC *
142 scResult.
cosC * bchk.lCovariance(1, 1) +
143 2 * scResult.
cosC * scResult.
sinC * locpo(0, 0) *
144 bchk.lCovariance(0, 1));
145 double max_ell = dx > dy ? dx : dy;
153 double min_ell = dx < dy ? dx : dy;
166 bool iterate(
double x,
174 std::vector<double> innerPolygonCoef(m_maxIterations + 1);
175 std::vector<double> outerPolygonCoef(m_maxIterations + 1);
188 for (
int t = 1; t <= m_maxIterations; t++) {
189 int numNodes = 4 << t;
190 innerPolygonCoef[t] = 0.5 / cos(2.0f*
M_PI / numNodes);
191 double c1x = (c0x + c2x) * innerPolygonCoef[t];
192 double c1y = (c0y + c2y) * innerPolygonCoef[t];
195 if (tx * tx + ty * ty <=
rr) {
198 double t2x = c2x - c1x;
199 double t2y = c2y - c1y;
200 if (tx * t2x + ty * t2y >= 0 &&
201 tx * t2x + ty * t2y <= t2x * t2x + t2y * t2y &&
202 (ty * t2x - tx * t2y >= 0 ||
203 rr * (t2x * t2x + t2y * t2y) >=
204 (ty * t2x - tx * t2y) * (ty * t2x - tx * t2y))) {
207 double t0x = c0x - c1x;
208 double t0y = c0y - c1y;
209 if (tx * t0x + ty * t0y >= 0 &&
210 tx * t0x + ty * t0y <= t0x * t0x + t0y * t0y &&
211 (ty * t0x - tx * t0y <= 0 ||
212 rr * (t0x * t0x + t0y * t0y) >=
213 (ty * t0x - tx * t0y) * (ty * t0x - tx * t0y))) {
216 outerPolygonCoef[t] =
217 0.5 / (std::cos(
M_PI / numNodes) * std::cos(
M_PI / numNodes));
218 double c3x = (c0x + c1x) * outerPolygonCoef[t];
219 double c3y = (c0y + c1y) * outerPolygonCoef[t];
220 if ((c3x -
x) * (c3x -
x) + (c3y -
y) * (c3y -
y) <
rr) {
225 double c4x = c1x - c3x + c1x;
226 double c4y = c1y - c3y + c1y;
227 if ((c4x -
x) * (c4x -
x) + (c4y -
y) * (c4y -
y) <
rr) {
232 double t3x = c3x - c1x;
233 double t3y = c3y - c1y;
234 if (ty * t3x - tx * t3y <= 0 ||
235 rr * (t3x * t3x + t3y * t3y) >
236 (ty * t3x - tx * t3y) * (ty * t3x - tx * t3y)) {
237 if (tx * t3x + ty * t3y > 0) {
238 if (std::abs(tx * t3x + ty * t3y) <= t3x * t3x + t3y * t3y ||
239 (
x - c3x) * (c0x - c3x) + (
y - c3y) * (c0y - c3y) >= 0) {
244 }
else if (-(tx * t3x + ty * t3y) <= t3x * t3x + t3y * t3y ||
245 (
x - c4x) * (c2x - c4x) + (
y - c4y) * (c2y - c4y) >= 0) {
260 bool collide(
double x0,
268 double x = std::abs(x1 - x0);
269 double y = std::abs(y1 - y0);
270 if (
x *
x + (
h -
y) * (
h -
y) <=
r *
r ||
271 (w -
x) * (w -
x) +
y *
y <=
r *
r ||
272 x *
h +
y * w <= w *
h
273 || ((
x *
h +
y * w - w *
h) * (
x *
h +
y * w - w *
h) <=
274 r *
r * (w * w +
h *
h) &&
275 x * w -
y *
h >= -
h *
h &&
276 x * w -
y *
h <= w * w)) {
279 if ((
x - w) * (
x - w) + (
y -
h) * (
y -
h) <=
r *
r ||
280 (
x <= w &&
y -
r <=
h) || (
y <=
h &&
x -
r <= w)) {
282 x,
y, w, 0, 0,
h,
r *
r);
298 covRotMatrix << scResult.
cosC, -locpo(0, 0) * scResult.
sinC, scResult.
sinC,
299 locpo(0, 0) * scResult.
cosC;
301 covRotMatrix * bchk.lCovariance * covRotMatrix.transpose();
302 Amg::Vector2D locpoCar(covRotMatrix(1, 1), -covRotMatrix(0, 1));
306 double w = bchk.
nSigmas * sqrt(lCovarianceCar(0, 0));
307 double h = bchk.
nSigmas * sqrt(lCovarianceCar(1, 1));
311 (lCovarianceCar(1, 0) != 0 &&
312 (lCovarianceCar(1, 1) - lCovarianceCar(0, 0)) != 0)
313 ? .5 * bchk.
FastArcTan(2 * lCovarianceCar(1, 0) /
314 (lCovarianceCar(1, 1) - lCovarianceCar(0, 0)))
320 double x1 = tmp(0, 0);
321 double y1 = tmp(1, 0);
324 return test.collide(x0, y0, w,
h, x1, y1,
r);