23#ifndef VCL_SPACE_CORE_PLANE_H
24#define VCL_SPACE_CORE_PLANE_H
45template<
typename Scalar,
bool NORM = true>
52 using ScalarType = Scalar;
55 static constexpr bool NORMED =
NORM;
71 Scalar
n = mDir.norm();
89 mOffset = p0.dot(mDir);
109 if constexpr (std::is_same<Scalar, S>::value) {
113 return Plane<S, NORM>(mDir.template cast<S>(), mOffset);
127 Scalar
offset()
const {
return mOffset; }
136 Scalar
k =
p.dot(mDir) - mOffset;
159 vcl::serialize(
os, mOffset);
169 vcl::deserialize(is, mOffset);
172 bool operator==(
const Plane&
p)
const
174 return mOffset ==
p.mOffset && mDir ==
p.mDir;
177 bool operator!=(
const Plane& p)
const {
return !(*
this == p); }
182using Planef = Plane<float>;
183using Planed = Plane<double>;
199 std::remove_cvref_t<T>,
200 Plane<typename RemoveRef<T>::ScalarType, RemoveRef<T>::NORMED>>;
A class representing a box in N-dimensional space.
Definition box.h:46
void deserialize(std::istream &is)
Deserializes the box from the given input stream.
Definition box.h:476
void serialize(std::ostream &os) const
Serializes the box to the given output stream.
Definition box.h:466
The Plane class represent a 2D plane in 3D space.
Definition plane.h:47
void deserialize(std::istream &is)
Deserializes the plane from the given input stream.
Definition plane.h:166
Point3< Scalar > projectPoint(const Point3< Scalar > &p) const
Given a point, returns the point projected to this plane.
Definition plane.h:134
Plane(const Point3< Scalar > &p0, const Point3< Scalar > &normal)
Constructor of a plane given a point lying to the plane and the normal of the plane.
Definition plane.h:83
Plane(const Point3< Scalar > &p0, const Point3< Scalar > &p1, const Point3< Scalar > &p2)
Constructor of a plane given three points.
Definition plane.h:98
Point3< Scalar > mirrorPoint(const Point3< Scalar > &p) const
Given a point, returns the point mirrored w.r.t. this plane.
Definition plane.h:145
Plane(const Point3< Scalar > &direction, Scalar offset)
Constructor of a plane given a direction and an offset.
Definition plane.h:67
Plane()
Empty constructor. The plane is uninitialized.
Definition plane.h:60
const Point3< Scalar > & direction() const
Returns the direction component of the plane.
Definition plane.h:121
void serialize(std::ostream &os) const
Serializes the plane to the given output stream.
Definition plane.h:156
Scalar offset() const
Returns the offset component of the plane.
Definition plane.h:127
A concept representing a Plane.
Definition plane.h:198