cee::Plane

class Plane

Class defining a plane in space.

The class describes a plane by the equation: Ax + By + Cz + Dx = 0 The plane’s normal is defined by the coefficients [A, B, C]

Public Functions

Plane()

Constructs a plane.

Plane(const Plane &other)

Constructs a plane as a copy of other.

Plane(double A, double B, double C, double D)

Constructs a plane based on the equation: Ax + By + Cz + Dx = 0.

Plane &operator=(const Plane &other)

Assigns other to this plane and returns a reference to this plane.

bool operator==(const Plane &rhs) const

Returns true if rhs is equal to this plane; otherwise returns false.

bool operator!=(const Plane &rhs) const

Returns true if rhs is NOT equal to this plane; otherwise returns false.

double A() const

Returns the value A.

Plane equation: Ax + By + Cz + Dx = 0

double B() const

Returns the value B.

Plane equation: Ax + By + Cz + Dx = 0

double C() const

Returns the value C.

Plane equation: Ax + By + Cz + Dx = 0

double D() const

Returns the value D.

Plane equation: Ax + By + Cz + Dx = 0

bool isValid() const

Returns true if the plane is valid, otherwise returns false.

double distance(const Vec3d &point) const

Returns the distance between the give point and this plane.

double distanceSquared(const Vec3d &point) const

Returns the square of the distance from the point to the plane.

The square of the distance is relatively fast to compute (no sqrt) and is useful for determine which side the point is on. To obtain the actual distance, divide by sqrt(A^2 + B^2 + C^2) or use the distance() function directly.

Vec3d normal() const

Returns the normal to this plane.

Vec3d pointInPlane() const

Gets a point located on the plane.

void set(double A, double B, double C, double D)

Sets A, B, C and D values for this plane.

Plane equation: Ax + By + Cz + Dx = 0

bool setFromPointAndNormal(const Vec3d &point, const Vec3d &normal)

Sets the plane from a point and a normal.

bool setFromPoints(const Vec3d &p1, const Vec3d &p2, const Vec3d &p3)

Sets the plane from three points.

The three points cannot be on a line as they need to define a plane. So (p2 - p1)*(p3 - p1) != 0

void transform(const Mat4d &matrix)

Transforms the plane with the given homogeneous transformation matrix.

bool rayIntersect(const Ray &ray, Vec3d *intersectionPoint) const

Calculates the intersection point between a ray and the plane.

Returns true if an intersection point was found

bool rayIntersect(const Ray &ray, double *distance) const

Calculates the distance between a ray and the plane.

Returns true if an intersection point was found

bool projectVector(const Vec3d &vector, Vec3d *projectedVector) const

Projects the given vector onto the plane.

Returns true if successfully projected. false if the given vector is parallel with the plane’s normal

Vec3d projectPoint(const Vec3d &point) const

Projects the given point onto the plane.

Public Static Functions

static Plane createFromPointAndNormal(const Vec3d &point, const Vec3d &normal)

Returns a plane created from a point and a normal.

static Plane createFromPoints(const Vec3d &p1, const Vec3d &p2, const Vec3d &p3)

Returns a plane created from three points.

The three points cannot be on a line as they need to define a plane. So (p2 - p1)*(p3 - p1) != 0