// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 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 "snap_to_fixed_up.h" template IGL_INLINE void igl::snap_to_fixed_up( const Eigen::Quaternion & q, Eigen::Quaternion & s) { using namespace Eigen; typedef Eigen::Matrix Vector3Q; const Vector3Q up = q.matrix() * Vector3Q(0,1,0); Vector3Q proj_up(0,up(1),up(2)); if(proj_up.norm() == 0) { proj_up = Vector3Q(0,1,0); } proj_up.normalize(); Quaternion dq; dq = Quaternion::FromTwoVectors(up,proj_up); s = dq * q; } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiations template void igl::snap_to_fixed_up(Eigen::Quaternion const&, Eigen::Quaternion&); template void igl::snap_to_fixed_up(Eigen::Quaternion const&, Eigen::Quaternion&); #endif