Ray-Impl.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_RAY_IMPL_HPP
12 #define CUBBYFLOW_RAY_IMPL_HPP
13 
14 namespace CubbyFlow
15 {
16 template <typename T, size_t N>
18 {
19  direction[0] = 1;
20 }
21 
22 template <typename T, size_t N>
23 Ray<T, N>::Ray(const VectorType& newOrigin, const VectorType& newDirection)
24  : origin(newOrigin), direction(newDirection.Normalized())
25 {
26  // Do nothing
27 }
28 
29 template <typename T, size_t N>
30 Ray<T, N>::Ray(const Ray& other)
31  : origin(other.origin), direction(other.direction)
32 {
33  // Do nothing
34 }
35 
36 template <typename T, size_t N>
37 Ray<T, N>::Ray(Ray&& other) noexcept
38  : origin(std::move(other.origin)), direction(std::move(other.direction))
39 {
40  // Do nothing
41 }
42 
43 template <typename T, size_t N>
45 {
46  origin = other.origin;
47  direction = other.direction;
48  return *this;
49 }
50 
51 template <typename T, size_t N>
53 {
54  origin = std::move(other.origin);
55  direction = std::move(other.direction);
56  return *this;
57 }
58 
59 template <typename T, size_t N>
61 {
62  return origin + t * direction;
63 }
64 } // namespace CubbyFlow
65 
66 #endif
VectorType origin
The origin of the ray.
Definition: Ray.hpp:35
Class for N-D ray.
Definition: Ray.hpp:25
VectorType PointAt(T t) const
Returns a point on the ray at distance t.
Definition: Ray-Impl.hpp:60
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
VectorType direction
The direction of the ray.
Definition: Ray.hpp:38
Ray()
Constructs an empty ray that points (1, 0, ...) from (0, 0, ...).
Definition: Ray-Impl.hpp:17
Ray & operator=(const Ray &other)
Copy assignment operator.
Definition: Ray-Impl.hpp:44