All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plane.h File Reference
#include "pxr/pxr.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/api.h"
#include <iosfwd>
#include <vector>
+ Include dependency graph for plane.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


class  GfPlane


GF_API bool GfFitPlaneToPoints (const std::vector< GfVec3d > &points, GfPlane *fitPlane)
GF_API std::ostream & operator<< (std::ostream &, const GfPlane &)

Function Documentation

GF_API bool GfFitPlaneToPoints ( const std::vector< GfVec3d > &  points,
GfPlane fitPlane 

Fits a plane to the given points. There must be at least three points in order to fit the plane; if the size of points is less than three, this issues a coding error.

If the points are all collinear, then no plane can be determined, and this function returns false. Otherwise, if the fitting is successful, it returns true and sets *fitPlane to the fitted plane. If points contains exactly three points, then the resulting plane is the exact plane defined by the three points. If points contains more than three points, then this function determines the best-fitting plane for the given points. The orientation of the plane normal is arbitrary with regards to the plane's positive and negative half-spaces; you can use GfPlane::Reorient() to flip the plane if necessary.

The current implementation uses linear least squares and thus defines "best-fitting" as minimizing the sum of the squares of the vertical distances between points and the plane surface.

GF_API std::ostream& operator<< ( std::ostream &  ,
const GfPlane  

Output a GfPlane using the format [(nx ny nz) distance].