From ebb3dc18b912148c4f4cf75a245b6e616e7ded2f Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 2 Nov 2015 15:15:27 +0100 Subject: [PATCH] Add some useful methods for RANSAC Planes --- .../include/CGAL/Shape_detection_3/Plane.h | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Point_set_shape_detection_3/include/CGAL/Shape_detection_3/Plane.h b/Point_set_shape_detection_3/include/CGAL/Shape_detection_3/Plane.h index 64af70b6aef..10f13fd75f6 100644 --- a/Point_set_shape_detection_3/include/CGAL/Shape_detection_3/Plane.h +++ b/Point_set_shape_detection_3/include/CGAL/Shape_detection_3/Plane.h @@ -85,7 +85,25 @@ namespace CGAL { return d * d; } - + /*! + Computes the orthogonal projection of a query point on the shape. + */ + Point_3 projection (const Point_3 &p) const { + Vector_3 v (m_point_on_primitive, p); + return m_point_on_primitive + (v * m_base1) * m_base1 + (v * m_base2) * m_base2; + } + + /*! + Replaces the plane by p + */ + void update (const Plane_3& p) { + m_base1 = p.base1 (); m_base2 = p.base2 (); m_normal = p.orthogonal_vector (); + m_d = -(this->get_x(m_point_on_primitive) * this->get_x(m_normal) + + this->get_y(m_point_on_primitive) * this->get_y(m_normal) + + this->get_z(m_point_on_primitive) * this->get_z(m_normal)); + + } + /*! Helper function to write the plane equation and number of assigned points into a string.