8 #ifndef META_OCEAN_MATH_SPHERE_3_H
9 #define META_OCEAN_MATH_SPHERE_3_H
174 static T
shortestDistance(
const T latitudeA,
const T longitudeA,
const T latitudeB,
const T longitudeB);
185 template <
typename T>
193 template <
typename T>
195 center_(boundingBox.center()),
196 radius_(boundingBox.diagonal() * T(0.5))
198 ocean_assert(boundingBox.
isValid());
202 template <
typename T>
208 template <
typename T>
214 template <
typename T>
217 ocean_assert(isValid());
225 template <
typename T>
228 ocean_assert(isValid());
229 ocean_assert(eps >= T(0));
237 template <
typename T>
240 ocean_assert(isValid());
253 const T b = (d * po) * 2;
254 const T c = po * po - radius_ * radius_;
256 return b * b >= 4 * a * c;
259 template <
typename T>
262 ocean_assert(sphere_T_ray.
isValid());
268 template <
typename T>
271 ocean_assert(isValid());
272 ocean_assert(sphere.
isValid());
280 template <
typename T>
283 return radius_ >= T(0);
286 template <
typename T>
289 ocean_assert(isValid());
290 ocean_assert(factor >= 0);
295 template <
typename T>
298 ocean_assert(isValid());
299 ocean_assert(factor >= T(0));
305 template <
typename T>
314 ocean_assert(coordinateVector.
isUnit());
316 return coordinateVector;
319 template <
typename T>
322 ocean_assert(coordinateVector.
isUnit());
336 template <
typename T>
344 const T latitudeDelta_2 = (latitudeB - latitudeA) * T(0.5);
345 const T longitudeDelta_2 = (longitudeB - longitudeA) * T(0.5);
348 ocean_assert(inner >= T(0));
This class implements an axis aligned 3D bounding box.
Definition: Box3.h:67
bool isValid() const
Returns whether the bounding box is valid.
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition: HomogenousMatrix4.h:1493
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
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 T atan2(const T y, const T x)
Returns the arctangent of a given value in radian.
Definition: Numeric.h:1632
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition: Numeric.h:1495
static T cos(const T value)
Returns the cosine of a given value.
Definition: Numeric.h:1584
static T asin(const T value)
Returns the arcsine of a given value.
Definition: Numeric.h:2887
bool isInsideEps(const VectorT3< T > &point, const T eps=NumericT< T >::eps()) const
Returns whether a given point is inside this sphere including a thin epsilon boundary.
Definition: Sphere3.h:226
bool isInside(const VectorT3< T > &point) const
Returns whether a given point is inside this sphere.
Definition: Sphere3.h:215
bool hasIntersection(const LineT3< T > &ray, const HomogenousMatrixT4< T > &sphere_T_ray) const
Returns whether a given ray has an intersection with this sphere.
Definition: Sphere3.h:260
VectorT3< T > center_
Sphere center.
Definition: Sphere3.h:179
bool isValid() const
Returns whether this radius of this sphere is not negative and thus the sphere is valid.
Definition: Sphere3.h:281
const T & radius() const
Returns the radius of the sphere.
Definition: Sphere3.h:209
T radius_
Sphere radius.
Definition: Sphere3.h:182
static VectorT3< T > coordinateToVector(const T latitude, const T longitude)
Converts a 2D location coordinate on the surface of a unit sphere to a vector with unit length.
Definition: Sphere3.h:306
SphereT3()=default
Creates an invalid sphere.
SphereT3(const BoxT3< T > &boundingBox)
Creates a new sphere entirely containing a given 3D box.
Definition: Sphere3.h:194
bool hasIntersection(const SphereT3< T > &sphere) const
Returns whether two spheres have an intersection.
Definition: Sphere3.h:269
static void vectorToCoordinate(const VectorT3< T > &coordinateVector, T &latitude, T &longitude)
Converts a vector pointing to the surface of a unit sphere to a 2D location coordinate.
Definition: Sphere3.h:320
bool hasIntersection(const LineT3< T > &ray) const
Returns whether a given ray has an intersection with this sphere.
Definition: Sphere3.h:238
SphereT3< T > operator*(const T factor) const
Returns a new sphere with an enlarged radius (the center of the sphere stays constant).
Definition: Sphere3.h:287
const VectorT3< T > & center() const
Returns the center of the sphere.
Definition: Sphere3.h:203
static T shortestDistance(const T latitudeA, const T longitudeA, const T latitudeB, const T longitudeB)
Calculates the shortest distance between two 2D location coordinates on the surface of a unit sphere.
Definition: Sphere3.h:337
SphereT3< T > & operator*=(const T factor)
Multiplies the radius of this sphere with a given factor.
Definition: Sphere3.h:296
SphereT3(const VectorT3< T > ¢er, const T radius)
Creates a new sphere by a center point and a radius.
Definition: Sphere3.h:186
This class implements a vector with three elements.
Definition: Vector3.h:97
bool isUnit(const T eps=NumericT< T >::eps()) const
Returns whether this vector is a unit vector (whether the vector has the length 1).
Definition: Vector3.h:861
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
SphereT3< float > SphereF3
Definition of a 3D sphere with float values.
Definition: Sphere3.h:42
std::vector< Sphere3 > Spheres3
Definition of a vector holding Shpere3 objects.
Definition: Sphere3.h:49
SphereT3< Scalar > Sphere3
Definition of the Sphere3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single...
Definition: Sphere3.h:21
SphereT3< double > SphereD3
Definition of a 3D sphere with double values.
Definition: Sphere3.h:35
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15