12 #include <klm/eklm/geometry/Line2D.h>
15 #include <klm/eklm/geometry/Circle2D.h>
21 m_Vector(vecx, vecy, 0)
34 return findIntersection(line, intersection, t);
41 double t[2], angles[2];
42 return findIntersection(circle, intersections, t, angles);
50 double t[2], angles[2];
52 n = findIntersection(arc, intersections, t, angles);
53 for (i = 0; i < n; i++)
55 return selectIntersections(intersections, condition, n);
71 double a1, a2, b1, b2, c1, c2, d, dt[2];
74 b1 = -line.getVector().x();
75 b2 = -line.getVector().y();
76 c1 = m_Point.x() - line.getInitialPoint().x();
77 c2 = m_Point.y() - line.getInitialPoint().y();
78 d = a1 * b2 - a2 * b1;
82 dt[0] = c1 * b2 - c2 * b1;
83 dt[1] = a1 * c2 - a2 * c1;
86 intersection->setX(m_Point.x() + m_Vector.x() * t[0]);
87 intersection->setY(m_Point.y() + m_Vector.y() * t[0]);
88 intersection->setZ(0);
100 double t[2],
double angles[2])
const
103 double a, b, c, d, x0, y0;
105 x0 = m_Point.x() - circleCenter.x();
106 y0 = m_Point.y() - circleCenter.y();
107 a = m_Vector.x() * m_Vector.x() + m_Vector.y() * m_Vector.y();
108 b = 2.0 * (m_Vector.x() * x0 + m_Vector.y() * y0);
110 d = b * b - 4 * a * c;
114 t[0] = -b / (2.0 * a);
115 intersections[0].setX(m_Point.x() + m_Vector.x() * t[0]);
116 intersections[0].setY(m_Point.y() + m_Vector.y() * t[0]);
117 intersections[0].setZ(0);
118 angles[0] = atan2(intersections[0].y() - circleCenter.y(),
119 intersections[0].x() - circleCenter.x());
122 t[0] = (-b - sqrt(d)) / (2.0 * a);
123 t[1] = (-b + sqrt(d)) / (2.0 * a);
124 for (i = 0; i < 2; i++) {
125 intersections[i].setX(m_Point.x() + m_Vector.x() * t[i]);
126 intersections[i].setY(m_Point.y() + m_Vector.y() * t[i]);
127 intersections[i].setZ(0);
128 angles[i] = atan2(intersections[i].y() - circleCenter.y(),
129 intersections[i].x() - circleCenter.x());
135 bool* condition,
int n)
const
139 for (i = 0; i < n; i++) {
142 intersections[j] = intersections[i];