Imath
<navlinks>
<page>

# Plane3

    #include <Imath/ImathPlane.h>

The `Plane3` class template represents a plane in 3D space, with predefined typedefs for planes of type `float` and `double`.

Example:

    #include <Imath/ImathPlane.h>
    #include <cassert>

    void
    plane3_example()
    {
        Imath::V3f a (1.0f, 0.0f, 0.0f);
        Imath::V3f b (0.0f, 1.0f, 0.0f);
        Imath::V3f c (0.0f, 0.0f, 1.0f);

        Imath::Plane3f p (a, b, c);

        Imath::V3f n (1.0f,  1.0f,  1.0f);
        n.normalize();

        assert (p.normal == n);

        Imath::V3f o (0.0f, 0.0f, 0.0f);
        float d = p.distanceTo (o);
        assert (Imath::equalWithAbsError (d, -0.57735f, 1e-6f));
    }

typedef Plane3<float> Imath::Plane3f

  Plane of type float.

typedef Plane3<double> Imath::Plane3d

  Plane of type double.

template<class T>
class Plane3

  The `Plane3` class represents a half space in 3D, so the normal may point either towards or away from origin.

  The plane `P` can be represented by Plane3 as either `p` or `-p` corresponding to the two half-spaces on either side of the plane. Any function which computes a distance will return either negative or positive values for the distance indicating which half-space the point is in. Note that reflection, and intersection functions will operate as expected.

  Direct access to member fields

  Vec3<T> normal

    The normal to the plane.

  T distance

    The distance from the origin to the plane.

  Constructors

  inline Plane3() noexcept

    Uninitialized by default.

  inline constexpr Plane3(const Vec3<T> &normal, T distance) noexcept

    Initialize with a normal and distance.

  inline constexpr Plane3(const Vec3<T> &point, const Vec3<T> &normal) noexcept

    Initialize with a point and a normal.

  inline constexpr Plane3(const Vec3<T> &point1, const Vec3<T> &point2, const Vec3<T> &point3) noexcept

    Initialize with three points.

  Manipulation

  inline void set(const Vec3<T> &normal, T distance) noexcept

    Set via a given normal and distance.

  inline void set(const Vec3<T> &point, const Vec3<T> &normal) noexcept

    Set via a given point and normal.

  inline void set(const Vec3<T> &point1, const Vec3<T> &point2, const Vec3<T> &point3) noexcept

    Set via three points.

  Utility Methods

  inline bool intersect(const Line3<T> &line, Vec3<T> &intersection) const noexcept

    Determine if a line intersects the plane.

    Parameters:

      - line – The line

      - intersection – [out] The point of intersection

    Returns:

      True if the line intersects the plane.

  inline bool intersectT(const Line3<T> &line, T &parameter) const noexcept

    Determine if a line intersects the plane.

    Parameters:

      - line – The line

      - parameter – [out] The parametric value of the point of intersection

    Returns:

      True if the line intersects the plane.

  inline T distanceTo(const Vec3<T> &point) const noexcept

    Return the distance from a point to the plane.

  inline Vec3<T> reflectPoint(const Vec3<T> &point) const noexcept

    Reflect the given point around the plane.

  inline Vec3<T> reflectVector(const Vec3<T> &vec) const noexcept

    Reflect the direction vector around the plane.

template<class T>
std::ostream &Imath::operator<<(std::ostream &o, const Plane3<T> &plane)

  Stream output, as “(normal distance)”.

</page>