8#ifndef META_OCEAN_MATH_CAMERA_H
9#define META_OCEAN_MATH_CAMERA_H
108 static T
fovX2Y(
const T fovX,
const T aspectRatio);
116 static T
fovY2X(
const T fovY,
const T aspectRatio);
183 template <
typename U = T>
193 template <
typename U = T>
203 template <
typename U = T>
213 template <
typename U>
223 template <
typename U>
233 template <
typename U>
243 template <
typename U>
253 template <
typename U>
263 template <
typename U>
273 template <
typename U>
283 template <
typename U>
293 template <
typename U>
305 template <
typename U>
318 template <
typename U>
331 template <
typename U>
343 template <
typename U>
355 template <
typename U>
367 template <
typename U>
377 template <
typename U>
388 template <
typename U>
399 template <
typename U>
409 template <
typename U>
419 template <
typename U>
429 template <
typename U>
472 ocean_assert(width > 0u);
475 const T width_2 = T(width) * T(0.5);
483 ocean_assert(world_T_camera.
isValid());
491 ocean_assert(flippedCamera_T_world.
isValid());
493 const VectorT3<T> transformedObjectPoint(flippedCamera_T_world * objectPoint);
501 const T factor = T(1) / transformedObjectPoint.
z();
502 return VectorT2<T>(transformedObjectPoint.
x() * factor, transformedObjectPoint.
y() * factor);
508 ocean_assert(world_T_camera.
isValid());
509 ocean_assert(numberObjectPoints == 0u || (objectPoints && normalizedImagePoints));
517 ocean_assert(flippedCamera_T_world.
isValid());
518 ocean_assert(numberObjectPoints == 0u || (objectPoints && normalizedImagePoints));
520 for (
unsigned int n = 0u; n < numberObjectPoints; ++n)
522 const VectorT3<T> transformedObjectPoint(flippedCamera_T_world * objectPoints[n]);
528 const T factor = T(1) / transformedObjectPoint.
z();
529 normalizedImagePoints[n].
x() = transformedObjectPoint.
x() * factor;
530 normalizedImagePoints[n].
y() = transformedObjectPoint.
y() * factor;
534 normalizedImagePoints[n].
x() = 0;
535 normalizedImagePoints[n].
y() = 0;
544 ocean_assert(
SquareMatrixT3<U>(1, 0, 0, 0, -1, 0, 0, 0, -1) ==
SquareMatrixT3<U>(
RotationT<U>(1, 0, 0,
NumericT<U>::pi())));
553 const U flipValues[16] =
588 result[1] = -result[1];
589 result[2] = -result[2];
591 result[5] = -result[5];
592 result[6] = -result[6];
594 result[9] = -result[9];
595 result[10] = -result[10];
597 result[13] = -result[13];
598 result[14] = -result[14];
618 result[4] = -result[4];
619 result[5] = -result[5];
620 result[6] = -result[6];
622 result[8] = -result[8];
623 result[9] = -result[9];
624 result[10] = -result[10];
644 result[1] = -result[1];
645 result[2] = -result[2];
647 result[4] = -result[4];
649 result[8] = -result[8];
651 result[13] = -result[13];
652 result[14] = -result[14];
671 result[1] = -result[1];
672 result[2] = -result[2];
674 result[4] = -result[4];
675 result[5] = -result[5];
677 result[7] = -result[7];
678 result[8] = -result[8];
712 result[1] = -result[1];
713 result[2] = -result[2];
715 result[3] = -result[3];
717 result[6] = -result[6];
750 flippedCameras_T_world.reserve(number);
752 for (
size_t n = 0; n < number; ++n)
757 return flippedCameras_T_world;
764 for (
size_t n = 0; n < number; ++n)
781 ocean_assert(world_T_camera.
isValid());
804 ocean_assert(flippedCamera_T_world.
isValid());
828 cameras_T_world.reserve(number);
830 for (
size_t n = 0; n < number; ++n)
835 return cameras_T_world;
842 for (
size_t n = 0; n < number; ++n)
858 ocean_assert(flippedCamera_T_world.
isValid());
859 ocean_assert(epsilon >= 0);
863 ocean_assert((flippedCamera_T_world[2] * objectPoint.
x() + flippedCamera_T_world[6] * objectPoint.
y() + flippedCamera_T_world[10] * objectPoint.
z() + flippedCamera_T_world[14] > epsilon) == ((flippedCamera_T_world * objectPoint).z() > epsilon));
864 return flippedCamera_T_world[2] * objectPoint.
x() + flippedCamera_T_world[6] * objectPoint.
y() + flippedCamera_T_world[10] * objectPoint.
z() + flippedCamera_T_world[14] > epsilon;
870 ocean_assert(!flippedCamera_R_world.
isNull());
871 ocean_assert(epsilon >= 0);
875 ocean_assert((flippedCamera_R_world[2] * objectPoint.
x() + flippedCamera_R_world[5] * objectPoint.
y() + flippedCamera_R_world[8] * objectPoint.
z() > epsilon) == ((flippedCamera_R_world * objectPoint).z() > epsilon));
876 return flippedCamera_R_world[2] * objectPoint.
x() + flippedCamera_R_world[5] * objectPoint.
y() + flippedCamera_R_world[8] * objectPoint.
z() > epsilon;
This class implements the base class for all cameras.
Definition Camera.h:99
static HomogenousMatricesT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > *world_T_cameras, const size_t number)
Transforms standard homogenous 4x4 viewing (extrinsic camera) matrices into an inverted and flipped c...
Definition Camera.h:747
static void invertedFlipped2Standard(const HomogenousMatrixT4< U > *flippedCameras_T_world, HomogenousMatrixT4< U > *world_T_cameras, const size_t number)
Transforms inverted and flipped camera matrices into standard viewing (extrinsic camera) matrices.
Definition Camera.h:840
static void standard2InvertedFlipped(const HomogenousMatrixT4< U > *world_T_cameras, HomogenousMatrixT4< U > *flippedCameras_T_world, const size_t number)
Transforms standard homogenous 4x4 viewing (extrinsic camera) matrices into an inverted and flipped c...
Definition Camera.h:762
static QuaternionT< U > flippedTransformationLeftSide(const QuaternionT< U > &left_Q_right)
Flips a quaternion around the x-axis by 180 degree.
Definition Camera.h:726
static HomogenousMatricesT4< U > invertedFlipped2Standard(const HomogenousMatricesT4< U > &flippedCameras_T_world)
Transforms inverted and flipped camera matrices into standard viewing (extrinsic camera) matrices.
Definition Camera.h:850
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
Transforms a standard homogenous 4x4 viewing (extrinsic camera) matrix into an inverted and flipped c...
Definition Camera.h:779
static void objectPoints2normalizedImagePointsIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > *objectPoints, const size_t numberObjectPoints, VectorT2< T > *normalizedImagePoints)
Calculates the normalized image points (the normalized projected object points) for a set of given ob...
Definition Camera.h:515
static QuaternionT< U > flipQuaternion()
Returns the quaternion flipping a rotation around the x-axis by 180 deg.
Definition Camera.h:568
static HomogenousMatrixT4< U > flipMatrix4()
Returns the 4x4 transformation matrix flipping a transformation around the x-axis by 180 deg.
Definition Camera.h:551
static SquareMatrixT3< U > flippedTransformationLeftSide(const SquareMatrixT3< U > &left_R_right)
Flips a 3x3 rotation matrix around the x-axis by 180 degree.
Definition Camera.h:661
static QuaternionT< U > standard2InvertedFlipped(const QuaternionT< U > &world_Q_camera)
Transforms a standard rotation quaternion into an inverted and flipped rotation quaternion.
Definition Camera.h:795
static VectorT2< T > objectPoint2normalizedImagePoint(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > &objectPoint)
Calculates the normalized image point (the normalized projected object point) for a of given object p...
Definition Camera.h:481
static VectorT2< T > objectPoint2normalizedImagePointIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint)
Calculates the normalized image point (the normalized projected object point) for a given object poin...
Definition Camera.h:489
static HomogenousMatrixT4< U > flippedTransformationRightSide(const HomogenousMatrixT4< U > &left_T_right)
Flips a transformation matrix around the x-axis by 180 degree.
Definition Camera.h:607
static T fieldOfViewToFocalLength(const unsigned int width, const T fovX)
Converts field of view (and width) to the corresponding focal length.
Definition Camera.h:470
static HomogenousMatrixT4< U > flippedTransformationLeftSide(const HomogenousMatrixT4< U > &left_T_right)
Flips a transformation matrix around the x-axis by 180 degree.
Definition Camera.h:577
static SquareMatrixT3< U > standard2InvertedFlipped(const SquareMatrixT3< U > &world_R_camera)
Transforms a standard 3x3 rotation matrix into an inverted and flipped rotation matrix.
Definition Camera.h:788
static QuaternionT< U > flippedTransformationLeftAndRightSide(const QuaternionT< U > &left_Q_right)
Flips a quaternion around the x-axis by 180 degree.
Definition Camera.h:740
static void objectPoints2normalizedImagePoints(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > *objectPoints, const size_t numberObjectPoints, VectorT2< T > *normalizedImagePoints)
Calculates the normalized image points (the normalized projected object points) for a set of given ob...
Definition Camera.h:506
static HomogenousMatrixT4< U > invertedFlipped2Standard(const HomogenousMatrixT4< U > &flippedCamera_T_world)
Transforms an inverted and flipped camera pose into a standard camera pose.
Definition Camera.h:802
static SquareMatrixT3< U > flipMatrix3()
Returns the 3x3 transformation matrix flipping a transformation around the x-axis by 180 deg.
Definition Camera.h:542
static SquareMatrixT3< U > flippedTransformationRightSide(const SquareMatrixT3< U > &left_R_right)
Flips a 3x3 rotation matrix around the x-axis by 180 degree.
Definition Camera.h:687
static HomogenousMatricesT4< U > standard2InvertedFlipped(const HomogenousMatricesT4< U > &world_T_cameras)
Transforms standard homogenous 4x4 viewing (extrinsic camera) matrices into an inverted and flipped c...
Definition Camera.h:772
static SquareMatrixT3< U > invertedFlipped2Standard(const SquareMatrixT3< U > &flippedCamera_R_world)
Transforms an inverted and flipped rotation matrix into a standard viewing rotation matrix.
Definition Camera.h:811
static QuaternionT< U > flippedTransformationRightSide(const QuaternionT< U > &left_Q_right)
Flips a quaternion around the x-axis by 180 degree.
Definition Camera.h:733
static bool isObjectPointInFrontIF(const SquareMatrixT3< T > &flippedCamera_R_world, const VectorT3< T > &objectPoint, const T epsilon=NumericT< T >::eps())
Determines whether a given 3D object point lies in front of a camera while the location of the camera...
Definition Camera.h:868
static HomogenousMatrixT4< U > flippedTransformationLeftAndRightSide(const HomogenousMatrixT4< U > &left_T_right)
Flips a transformation matrix around the x-axis by 180 degree.
Definition Camera.h:633
static T fovY2X(const T fovY, const T aspectRatio)
Calculates the horizontal FOV from the vertical FOV and the aspect ratio of the camera image.
Definition Camera.h:462
static QuaternionT< U > invertedFlipped2Standard(const QuaternionT< U > &flippedCamera_Q_world)
Transforms an inverted and flipped rotation quaternion into a standard viewing rotation quaternion.
Definition Camera.h:818
static T fovX2Y(const T fovX, const T aspectRatio)
Calculates the vertical FOV from the horizontal FOV and the aspect ratio of the camera image.
Definition Camera.h:454
static SquareMatrixT3< U > flippedTransformationLeftAndRightSide(const SquareMatrixT3< U > &left_R_right)
Flips a 3x3 rotation matrix around the x-axis by 180 degree.
Definition Camera.h:702
static bool isObjectPointInFrontIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, const T epsilon=NumericT< T >::eps())
Determines whether a given 3D object point lies in front of a camera while the location of the camera...
Definition Camera.h:856
static HomogenousMatricesT4< U > invertedFlipped2Standard(const HomogenousMatrixT4< U > *flippedCameras_T_world, const size_t number)
Transforms inverted and flipped camera matrices into standard viewing (extrinsic camera) matrices.
Definition Camera.h:825
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition HomogenousMatrix4.h:110
HomogenousMatrixT4< T > inverted() const noexcept
Returns the inverted of this matrix.
Definition HomogenousMatrix4.h:1569
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1800
static T atan(const T value)
Returns the arctangent of a given value.
Definition Numeric.h:1620
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition Numeric.h:926
static constexpr T eps()
Returns a small epsilon.
static T tan(const T value)
Returns the tangent of a given value.
Definition Numeric.h:1604
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 unit quaternion rotation.
Definition Quaternion.h:100
QuaternionT< T > inverted() const
Returns the inverted quaternion.
Definition Quaternion.h:737
This class implements a axis-angle rotation using floating point values.
Definition Rotation.h:73
This class implements a 3x3 square matrix.
Definition SquareMatrix3.h:89
VectorT3< T > xAxis() const
Returns the x axis which is the first column of the matrix.
Definition SquareMatrix3.h:1397
bool isNull() const
Returns whether this matrix is a zero matrix.
Definition SquareMatrix3.h:1334
VectorT3< T > zAxis() const
Returns the z axis which is the last column of the matrix.
Definition SquareMatrix3.h:1409
VectorT3< T > yAxis() const
Returns the y axis which is the middle column of the matrix.
Definition SquareMatrix3.h:1403
SquareMatrixT3< T > inverted() const
Returns the inverted matrix of this matrix.
Definition SquareMatrix3.h:1177
This class implements a vector with two elements.
Definition Vector2.h:96
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:703
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:715
This class implements a vector with three elements.
Definition Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:816
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:804
const T & z() const noexcept
Returns the z value.
Definition Vector3.h:828
CameraT< Scalar > Camera
Definition of an Camera object with Scalar precision.
Definition Camera.h:30
CameraT< double > CameraD
Definition of an Camera object with double precision.
Definition Camera.h:37
std::vector< HomogenousMatrixT4< T > > HomogenousMatricesT4
Definition of a typename alias for vectors with HomogenousMatrixT4 objects.
Definition HomogenousMatrix4.h:66
CameraT< float > CameraF
Definition of an Camera object with float precision.
Definition Camera.h:44
The namespace covering the entire Ocean framework.
Definition Accessor.h:15