8#ifndef META_OCEAN_MATH_CYLINDER_3_H
9#define META_OCEAN_MATH_CYLINDER_3_H
178 axis_(0.0, 0.0, 0.0),
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);
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_;
This class implements a 3D cylinder defined by its origin, axis, radius, and (signed) starting and st...
Definition Cylinder3.h:80
VectorT3< Scalar > origin_
Definition Cylinder3.h:160
const Scalar & maxSignedDistanceAlongAxis() const
bool isValid() const
Returns whether this cylinder is valid.
Definition Cylinder3.h:312
const VectorT3< Scalar > & axis() const
const Scalar & radius() const
CylinderT3(const VectorT3< T > &origin, const VectorT3< T > &axis, const T radius, const T height)
Defines a new cylinder with a base along its axis at distance = 0 and with the specified height (posi...
Definition Cylinder3.h:187
Scalar maxSignedDistanceAlongAxis_
Definition Cylinder3.h:172
VectorT3< Scalar > axis_
Definition Cylinder3.h:163
CylinderT3(const VectorT3< T > &origin, const VectorT3< T > &axis, const T radius, const T minSignedDistanceAlongAxis, const T maxSignedDistanceAlongAxis)
Defines a new cylinder.
Definition Cylinder3.h:194
Scalar radius_
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
CylinderT3()
Creates an invalid cylinder.
Definition Cylinder3.h:176
const VectorT3< Scalar > & origin() const
const Scalar & minSignedDistanceAlongAxis() const
Scalar minSignedDistanceAlongAxis_
Definition Cylinder3.h:169
static bool solveQuadratic(const T a, const T b, const T c, T &x1, T &x2)
Solves an quadratic equation with the form:
Definition Equation.h:168
This class implements an infinite line in 3D space.
Definition Line3.h:69
bool isValid() const
Returns whether this line has valid parameters.
Definition Line3.h:312
const VectorT3< T > & direction() const
Returns the direction of the line.
Definition Line3.h:293
const VectorT3< T > & point() const
Returns a point on the line.
Definition Line3.h:280
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition Numeric.h:2395
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2096
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
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:674
std::vector< Cylinder3 > Cylinders3
Definition of a vector holding Cylinder3 objects.
Definition Cylinder3.h:51
CylinderT3< double > CylinderD3
Definition of a 3D cylinder with double values.
Definition Cylinder3.h:37
CylinderT3< Scalar > Cylinder3
Definition of the Cylinder3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Cylinder3.h:30
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