Carna Version 3.3.3
Loading...
Searching...
No Matches
RaySphereHitTest.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2015 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 */
11
12#ifndef RAYSPHEREHITTEST_H_6014714286
13#define RAYSPHEREHITTEST_H_6014714286
14
15#include <Carna/Carna.h>
16#include <Carna/base/math.h>
17#include <Carna/base/math/Ray.h>
19
24namespace Carna
25{
26
27namespace base
28{
29
30namespace math
31{
32
33
34
35// ----------------------------------------------------------------------------------
36// RaySphereHitTest
37// ----------------------------------------------------------------------------------
38
48template< typename VectorType, typename ScalarType >
50{
51
52 bool myHitExists;
53 VectorType myHitLocation;
54
55public:
56
63
69 void compute( const Ray< VectorType >& ray, const ScalarType radius );
70
74 bool hitExists() const;
75
81 const VectorType& hitLocation() const;
82
83}; // RaySphereHitTest
84
85
86template< typename VectorType, typename ScalarType >
91
92
93template< typename VectorType, typename ScalarType >
95{
96 return myHitExists;
97}
98
99
100template< typename VectorType, typename ScalarType >
102{
103 CARNA_ASSERT( hitExists() );
104 return myHitLocation;
105}
106
107
108template< typename VectorType, typename ScalarType >
110{
111 CARNA_ASSERT( isEqual< ScalarType >( ray.direction.norm(), 1 ) );
113 CARNA_ASSERT( ray.direction.rows() == ray.origin.rows() && ray.origin.rows() == planeNormal.rows() );
114 CARNA_ASSERT( ray.direction.cols() == ray.origin.cols() && ray.origin.cols() == planeNormal.cols() && planeNormal.cols() == 1 );
115
116 ;
117}
118
119
120
121} // namespace Carna :: base :: math
122
123} // namespace Carna :: base
124
125} // namespace Carna
126
127#endif // RAYSPHEREHITTEST_H_6014714286
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Defines Carna::base::math::Ray.
Represents an association.
Definition Association.h:45
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 Carna::base::math namespace and CARNA_FOR_VECTOR3UI.