geolib2
src
Ray.cpp
Go to the documentation of this file.
1
#include "
geolib/Ray.h
"
2
3
namespace
geo
{
4
5
Ray::Ray
(
const
Vector3
&o,
const
Vector3
&d) : origin_(o), direction_(d.normalized()), length_(0)
6
{
7
calculateInvDirection
();
8
9
sign_
[0] = (
direction_
.
x
< 0);
10
sign_
[1] = (
direction_
.
y
< 0);
11
sign_
[2] = (
direction_
.
z
< 0);
12
}
13
14
void
Ray::calculateInvDirection
()
15
{
16
// Hardcoded EPS
17
double
inv_x = std::abs(
direction_
.
x
) < 1e-9 ? 0 : 1/
direction_
.
x
;
18
double
inv_y = std::abs(
direction_
.
y
) < 1e-9 ? 0 : 1/
direction_
.
y
;
19
double
inv_z = std::abs(
direction_
.
z
) < 1e-9 ? 0 : 1/
direction_
.
z
;
20
21
inv_direction_
=
geo::Vector3
(inv_x, inv_y, inv_z);
22
}
23
24
}
geo::Vector3::y
const real & y() const
Definition:
matrix.h:32
geo::Vector3
Vec3 Vector3
Definition:
datatypes.h:32
geo::Ray::direction_
Vector3 direction_
Definition:
Ray.h:32
geo
Definition:
Box.h:6
geo::Ray::calculateInvDirection
void calculateInvDirection()
Definition:
Ray.cpp:14
geo::Ray::sign_
std::array< int, 3 > sign_
Definition:
Ray.h:38
geo::Ray::inv_direction_
Vector3 inv_direction_
Definition:
Ray.h:34
geo::Vector3
Definition:
matrix.h:12
geo::Vector3::z
const real & z() const
Definition:
matrix.h:33
geo::Vector3::x
const real & x() const
Definition:
matrix.h:31
Ray.h
geo::Ray::Ray
Ray(const Vector3 &o, const Vector3 &d)
Definition:
Ray.cpp:5
Generated on Sun Feb 23 2025 04:33:29 for geolib2 by
1.8.17