8 #ifndef META_OCEAN_MATH_CYLINDER_3_H
9 #define META_OCEAN_MATH_CYLINDER_3_H
123 inline const T&
radius()
const;
175 template <
typename T>
177 origin_(0.0, 0.0, 0.0),
178 axis_(0.0, 0.0, 0.0),
180 minSignedDistanceAlongAxis_(0.0),
181 maxSignedDistanceAlongAxis_(0.0)
186 template <
typename T>
188 CylinderT3(origin, axis, radius, T(0.0), height)
193 template <
typename T>
198 minSignedDistanceAlongAxis_(minSignedDistanceAlongAxis),
199 maxSignedDistanceAlongAxis_(maxSignedDistanceAlongAxis)
205 template <
typename T>
211 template <
typename T>
217 template <
typename T>
223 template <
typename T>
226 return minSignedDistanceAlongAxis_;
229 template <
typename T>
232 return maxSignedDistanceAlongAxis_;
235 template <
typename T>
238 return maxSignedDistanceAlongAxis_ - minSignedDistanceAlongAxis_;
241 template <
typename T>
244 ocean_assert(isValid() && ray.
isValid());
274 const T d_dot_q = d * q;
275 const T d_dot_d = d.
sqr();
276 const T V_dot_q = V * q;
277 const T V_dot_d = V * d;
278 const T V_dot_V = V.
sqr();
280 const T a = d_dot_d - d_dot_q * d_dot_q;
281 const T b = T(2.) * (V_dot_d - d_dot_q * V_dot_q);
282 const T c = V_dot_V - V_dot_q * V_dot_q - radius_ * radius_;
284 T minDistance = T(-1.), maxDistance = T(-1.);
288 minDistance = min(minDistance, maxDistance);
296 minDistance = -c / b;
300 if (minDistance < T(0.))
305 intersection = ray.
point(minDistance);
307 const T distanceAlongAxis = (intersection - origin_) * axis_;
308 return (distanceAlongAxis >= minSignedDistanceAlongAxis_ && distanceAlongAxis <= maxSignedDistanceAlongAxis_);
311 template <
typename T>
314 return radius_ > T(0.) && maxSignedDistanceAlongAxis_ >= minSignedDistanceAlongAxis_ &&
NumericT<T>::isEqual(axis_.sqr(), T(1.));
This class implements a 3D cylinder defined by its origin, axis, radius, and (signed) starting and st...
Definition: Cylinder3.h:80
VectorT3< T > origin_
Center of the cylinder's base.
Definition: Cylinder3.h:160
const T & maxSignedDistanceAlongAxis() const
Returns the maximum signed truncation distance along the cylinder's axis.
Definition: Cylinder3.h:230
bool isValid() const
Returns whether this cylinder is valid.
Definition: Cylinder3.h:312
const VectorT3< T > & axis() const
Returns the unit-length axis of the cylinder.
Definition: Cylinder3.h:212
const T & radius() const
Returns the radius of the cylinder.
Definition: Cylinder3.h:218
T maxSignedDistanceAlongAxis_
Maximum signed truncation distance along the cone's axis.
Definition: Cylinder3.h:172
VectorT3< T > axis_
Cylinder axis, a unit vector.
Definition: Cylinder3.h:163
T radius_
Radius of the cylinder.
Definition: Cylinder3.h:166
bool nearestIntersection(const LineT3< T > &ray, VectorT3< T > &point) const
Returns the closest point of intersection of a ray with the outer surface of the cylinder,...
Definition: Cylinder3.h:242
T height() const
Returns the length of the cylinder along its axis.
Definition: Cylinder3.h:236
CylinderT3()
Creates an invalid cylinder.
Definition: Cylinder3.h:176
const VectorT3< T > & origin() const
Returns the center of the cylinder's base.
Definition: Cylinder3.h:206
const T & minSignedDistanceAlongAxis() const
Returns the minimum signed truncation distance along the cylinder's axis.
Definition: Cylinder3.h:224
T minSignedDistanceAlongAxis_
Minimum signed truncation distance along the cone's axis.
Definition: Cylinder3.h:169
This class provides several functions to solve equations with different degree using floating point v...
Definition: Equation.h:53
This class implements an infinite line in 3D space.
Definition: Line3.h:70
bool isValid() const
Returns whether this line has valid parameters.
Definition: Line3.h:303
const VectorT3< T > & direction() const
Returns the direction of the line.
Definition: Line3.h:284
const VectorT3< T > & point() const
Returns a point on the line.
Definition: Line3.h:271
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
This class implements a vector with three elements.
Definition: Vector3.h:97
T sqr() const
Returns the square of the vector length.
Definition: Vector3.h:670
CylinderT3< double > CylinderD3
Definition of a 3D cylinder with double values.
Definition: Cylinder3.h:37
std::vector< Cylinder3 > Cylinders3
Definition of a vector holding Cylinder3 objects.
Definition: Cylinder3.h:51
CylinderT3< Scalar > Cylinder3
Definition of the Cylinder3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition: Cylinder3.h:23
CylinderT3< float > CylinderF3
Definition of a 3D cylinder with float values.
Definition: Cylinder3.h:44
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15