Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
sv::Plane Class Reference

A 3D plane. More...

#include <sceneview/plane.hpp>

Public Member Functions

 Plane ()
 Construct an invalid plane with zero coefficients.
 
 Plane (float a, float b, float c, float d)
 Construct a plane with the specified parameters. More...
 
 Plane (const QVector3D &normal, float d)
 Construct a plane with the specified parameters. More...
 
float SignedDistance (const QVector3D &point) const
 Computes the signed distance of a point from the plane. More...
 
const QVector3D & Normal () const
 Returns the plane's normal vector $ \mathbf{n} = (a, b, c) $.
 
float D () const
 Returns the plane's d parameter.
 

Static Public Member Functions

static Plane FromThreePoints (const QVector3D &p1, const QVector3D &p2, const QVector3D &p3)
 Create a plane from three points. More...
 

Detailed Description

A 3D plane.

The plane is represented interally as the parameters

\[ (a, b, c, d) \]

with the plane's normal vector given as $ \mathbf{n} = (a, b, c) $ and $ || \mathbf{n} || = 1 $.

All points $(x, y, z)$ on the plane satisfy:

\[ a x + b y + c z + d = 0 \]

Constructor & Destructor Documentation

sv::Plane::Plane ( float  a,
float  b,
float  c,
float  d 
)

Construct a plane with the specified parameters.

Interally, the parameters are scaled so that $|| (a, b, c)|| = 1$

sv::Plane::Plane ( const QVector3D &  normal,
float  d 
)

Construct a plane with the specified parameters.

Interally, the parameters are scaled so that $|| (a, b, c)|| = 1$

Member Function Documentation

static Plane sv::Plane::FromThreePoints ( const QVector3D &  p1,
const QVector3D &  p2,
const QVector3D &  p3 
)
static

Create a plane from three points.

The plane normal vector is taken as the cross product of (p2 - p1) with (p3 - p1):

\[ \mathbf{n} = (\mathbf{p_2} - \mathbf{p_1}) \times (\mathbf{p_3} - \mathbf{p_1}) \]

The normal vector is then scaled to be unit length, and a suitable value for d is chosen automatically.

float sv::Plane::SignedDistance ( const QVector3D &  point) const

Computes the signed distance of a point from the plane.

The point has a positive distance from the plane if the vector from the plane to the point has a positive dot product with the plane's normal vector.

Specifically, this method computes:

\[ \mathbf{n} \cdot \mathbf{point} + d \]

This method can be used as a half-plane test to determine which side of the plane the point lies on. This is particularly useful for view frustum culling.


The documentation for this class was generated from the following file: