All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages

plane.h File Reference

Include dependency graph for plane.h:

Go to the source code of this file.

## Classes | |

class | GfPlane |

Basic type: 3-dimensional plane. More... | |

## Functions | |

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

Fits a plane to the given `points` . More... | |

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

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

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.