/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_DARKROOM_RAYS_RAY_HPP #define SPROUT_DARKROOM_RAYS_RAY_HPP #include #include #include #include #include #include namespace sprout { namespace darkroom { namespace rays { // // position // direction // template inline SPROUT_CONSTEXPR auto position(T&& t) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(SPROUT_FORWARD(T, t)))) -> decltype(sprout::darkroom::access::get<0>(SPROUT_FORWARD(T, t))) { return sprout::darkroom::access::get<0>(SPROUT_FORWARD(T, t)); } template inline SPROUT_CONSTEXPR auto direction(T&& t) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(SPROUT_FORWARD(T, t)))) -> decltype(sprout::darkroom::access::get<1>(SPROUT_FORWARD(T, t))) { return sprout::darkroom::access::get<1>(SPROUT_FORWARD(T, t)); } // // make_ray // template inline SPROUT_CONSTEXPR sprout::tuples::tuple make_ray(Position const& pos, Direction const& dir) { return sprout::tuples::make_tuple(pos, dir); } // // ray // typedef sprout::tuples::tuple ray; // // point_of_intersection // template inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit::type point_of_intersection(Ray const& ray, Distance const& dist) { return sprout::darkroom::coords::add( sprout::darkroom::rays::position(ray), sprout::darkroom::coords::scale(sprout::darkroom::rays::direction(ray), dist) ); } // // detach_position // template inline SPROUT_CONSTEXPR Position detach_position(Position const& pos, Direction const& dir) { return sprout::darkroom::coords::add( pos, sprout::darkroom::coords::resize( dir, sprout::numeric_limits::type>::epsilon() * 256 ) ); } // // make_detached_ray // template inline SPROUT_CONSTEXPR sprout::tuples::tuple make_detached_ray(Position const& pos, Direction const& dir) { return sprout::darkroom::rays::make_ray( sprout::darkroom::rays::detach_position(pos, dir), dir ); } } // namespace rays } // namespace darkroom } // namespace sprout #endif // #ifndef SPROUT_DARKROOM_RAYS_RAY_HPP