35 const tf::Vector3& plane_normal,
36 const tf::Vector3& plane_point,
37 const tf::Vector3& point)
39 return plane_normal.normalized().dot(point - plane_point);
43 const tf::Vector3& plane_normal,
44 const tf::Vector3& plane_point,
45 const tf::Vector3& point)
48 return point - plane_normal *
d;
52 const tf::Vector3& line_start,
53 const tf::Vector3& line_end,
54 const tf::Vector3& point)
60 const cv::Vec2d& line_start,
61 const cv::Vec2d& line_end,
62 const cv::Vec2d& point)
66 (point[0] - proj[0]) * (point[0] - proj[0]) +
67 (point[1] - proj[1]) * (point[1] - proj[1]));
71 const tf::Vector3& line_start,
72 const tf::Vector3& line_end,
73 const tf::Vector3& point)
75 tf::Vector3 v = line_end - line_start;
76 tf::Vector3 r = point - line_start;
90 return line_start + (t / b) * v;
95 const cv::Vec2d& line_start,
96 const cv::Vec2d& line_end,
97 const cv::Vec2d& point)
99 cv::Point2d v(line_end - line_start);
100 cv::Point2d r(point - line_start);
116 return line_start + cv::Vec2d(v.x * (t / b), v.y * (t / b));
120 const std::vector<cv::Vec2d>& polygon,
121 const cv::Vec2d& point)
123 if (polygon.size() < 2)
128 bool is_inside =
false;
129 if (((polygon.front()[1] > point[1]) != (polygon.back()[1] > point[1])) &&
130 (point[0] < (polygon.back()[0] - polygon.front()[0]) * (point[1] - polygon.front()[1]) /
131 (polygon.back()[1] - polygon.front()[1]) + polygon.front()[0]))
133 is_inside = !is_inside;
136 for (
size_t i = 1; i < polygon.size(); i++)
138 if (((polygon[i][1] > point[1]) != (polygon[i - 1][1] > point[1])) &&
139 (point[0] < (polygon[i - 1][0] - polygon[i][0]) * (point[1] - polygon[i][1]) /
140 (polygon[i - 1][1] - polygon[i][1]) + polygon[i][0]))
142 is_inside = !is_inside;
150 const std::vector<cv::Vec2d>& polygon,
151 const cv::Vec2d& point)
159 for (
size_t i = 1; i < polygon.size(); i++)
168 const tf::Vector3& a1,
169 const tf::Vector3& a2,
170 const tf::Vector3& b1,
171 const tf::Vector3& b2,
174 tf::Vector3 u = a1 - a2;
175 tf::Vector3 v = b1 - b2;
176 if (u.length() == 0 || v.length() == 0)
180 tf::Vector3 w = u.cross(v);
181 tf::Vector3
s = b1 - a1;
192 tf::Vector3 x = a1 + u * (
s.cross(v).dot(w) /
f);
193 tf::Vector3 y = b1 + v * (
s.cross(u).dot(w) /
f);