// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "unproject_ray.h" #include "unproject.h" template < typename Derivedpos, typename Derivedmodel, typename Derivedproj, typename Derivedviewport, typename Deriveds, typename Deriveddir> IGL_INLINE void igl::unproject_ray( const Eigen::PlainObjectBase & pos, const Eigen::PlainObjectBase & model, const Eigen::PlainObjectBase & proj, const Eigen::PlainObjectBase & viewport, Eigen::PlainObjectBase & s, Eigen::PlainObjectBase & dir) { using namespace std; using namespace Eigen; // Source and direction on screen typedef Eigen::Matrix Vec3; Vec3 win_s(pos(0),pos(1),0); Vec3 win_d(pos(0),pos(1),1); // Source, destination and direction in world Vec3 d; igl::unproject(win_s,model,proj,viewport,s); igl::unproject(win_d,model,proj,viewport,d); dir = d-s; } #ifdef IGL_STATIC_LIBRARY template void igl::unproject_ray, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif