Skip to content

Commit

Permalink
Fix bugs in cone visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-outotec authored and taketwo committed Sep 2, 2014
1 parent 5c8fa8a commit 9ac5bf6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
22 changes: 21 additions & 1 deletion visualization/include/pcl/visualization/common/shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,27 @@ namespace pcl
create2DCircle (const pcl::ModelCoefficients &coefficients, double z = 0.0);

/** \brief Create a cone shape from a set of model coefficients.
* \param[in] coefficients the cone coefficients (point_on_axis, axis_direction, radius)
* \param[in] coefficients the cone coefficients (cone_apex, axis_direction, angle)
*
* \code
* // The following are given (or computed using sample consensus techniques -- see SampleConsensusModelCone)
* // Eigen::Vector3f cone_apex, axis_direction;
* // float angle;
* // Note: The height of the cone is set using the magnitude of the axis_direction vector.
*
* pcl::ModelCoefficients cone_coeff;
* plane_coeff.values.resize (7); // We need 7 values
* plane_coeff.values[0] = cone_apex.x ();
* plane_coeff.values[1] = cone_apex.y ();
* plane_coeff.values[2] = cone_apex.z ();
* plane_coeff.values[3] = axis_direction.x ();
* plane_coeff.values[4] = axis_direction.y ();
* plane_coeff.values[5] = axis_direction.z ();
* plane_coeff.values[6] = angle (); // degrees
*
* vtkSmartPointer<vtkDataSet> data = pcl::visualization::createCone (cone_coeff);
* \endcode
*
* \ingroup visualization
*/
PCL_EXPORTS vtkSmartPointer<vtkDataSet>
Expand Down
10 changes: 6 additions & 4 deletions visualization/src/common/shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,12 @@ vtkSmartPointer<vtkDataSet>
pcl::visualization::createCone (const pcl::ModelCoefficients &coefficients)
{
vtkSmartPointer<vtkConeSource> cone = vtkSmartPointer<vtkConeSource>::New ();
cone->SetHeight (1.0);
cone->SetCenter (coefficients.values[0] + coefficients.values[3] * 0.5,
coefficients.values[1] + coefficients.values[1] * 0.5,
coefficients.values[2] + coefficients.values[2] * 0.5);
cone->SetHeight (std::sqrt (coefficients.values[3] * coefficients.values[3] +
coefficients.values[4] * coefficients.values[4] +
coefficients.values[5] * coefficients.values[5]));
cone->SetCenter (coefficients.values[0] + coefficients.values[3] * 0.5,
coefficients.values[1] + coefficients.values[4] * 0.5,
coefficients.values[2] + coefficients.values[5] * 0.5);
cone->SetDirection (-coefficients.values[3], -coefficients.values[4], -coefficients.values[5]);
cone->SetResolution (100);
cone->SetAngle (coefficients.values[6]);

This comment has been minimized.

Copy link
@stefanbuettner

stefanbuettner Dec 2, 2015

Contributor

Is there a reason why the angle in coefficients is not expected to be in radians as returned by the cone sac model? Would it make sense to change that as well?

Expand Down

0 comments on commit 9ac5bf6

Please sign in to comment.