LibCarna Version 3.4.0
Loading...
Searching...
No Matches
RaySphereHitTest.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#ifndef RAYSPHEREHITTEST_H_6014714286
16#define RAYSPHEREHITTEST_H_6014714286
17
18#include <LibCarna/LibCarna.hpp>
22
28namespace LibCarna
29{
30
31namespace base
32{
33
34namespace math
35{
36
37
38
39// ----------------------------------------------------------------------------------
40// RaySphereHitTest
41// ----------------------------------------------------------------------------------
42
51template< typename VectorType, typename ScalarType >
53{
54
55 bool myHitExists;
56 VectorType myHitLocation;
57
58public:
59
66
72 void compute( const Ray< VectorType >& ray, const ScalarType radius );
73
77 bool hitExists() const;
78
84 const VectorType& hitLocation() const;
85
86}; // RaySphereHitTest
87
88
89template< typename VectorType, typename ScalarType >
94
95
96template< typename VectorType, typename ScalarType >
98{
99 return myHitExists;
100}
101
102
103template< typename VectorType, typename ScalarType >
105{
106 LIBCARNA_ASSERT( hitExists() );
107 return myHitLocation;
108}
109
110
111template< typename VectorType, typename ScalarType >
113{
114 LIBCARNA_ASSERT( isEqual< ScalarType >( ray.direction.norm(), 1 ) );
116 LIBCARNA_ASSERT( ray.direction.rows() == ray.origin.rows() && ray.origin.rows() == planeNormal.rows() );
117 LIBCARNA_ASSERT( ray.direction.cols() == ray.origin.cols() && ray.origin.cols() == planeNormal.cols() && planeNormal.cols() == 1 );
118
119 ;
120}
121
122
123
124} // namespace LibCarna :: base :: math
125
126} // namespace LibCarna :: base
127
128} // namespace LibCarna
129
130#endif // RAYSPHEREHITTEST_H_6014714286
Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.
#define LIBCARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Contains forward-declarations.
Defines LibCarna::base::math::Ray.
Represents an association.
Tests whether sphere in origin is hit by a Ray object.
bool hitExists() const
Tells whether a hit exists.
const VectorType & hitLocation() const
References the location of the hit.
void compute(const Ray< VectorType > &ray, const ScalarType radius)
Performs a hit test of ray with a sphere of radius radius. The sphere is assumed to be centered in th...
Defines LibCarna::base::math namespace and LIBCARNA_FOR_VECTOR3UI.