#include "projection_constraint.h" template < typename DerivedUV, typename DerivedM, typename DerivedVP, typename DerivedA, typename DerivedB> void igl::projection_constraint( const Eigen::MatrixBase & UV, const Eigen::MatrixBase & _M, const Eigen::MatrixBase & VP, Eigen::PlainObjectBase & A, Eigen::PlainObjectBase & B) { typedef typename DerivedA::Scalar Scalar; const Scalar u = UV(0); const Scalar v = UV(1); const Scalar cu = VP(0); const Scalar cv = VP(1); const Scalar w = VP(2); const Scalar h = VP(3); // u = cu + w*(0.5 + 0.5*((M.row(0)*X) / (M.row(3)*X) )) // u-cu = w*(0.5 + 0.5*((M.row(0)*X) / (M.row(3)*X) )) // (u-cu)/w = 0.5 + 0.5*((M.row(0)*X) / (M.row(3)*X) ) // (u-cu)/w - 0.5 = 0.5*((M.row(0)*X) / (M.row(3)*X) ) // 2.*(u-cu)/w - 1 = ((M.row(0)*X) / (M.row(3)*X) ) // (2.*(u - cu)/w - 1) * M.row(3)*X = M.row(0)*X // (2.*(u - cu)/w - 1) * M.row(3)*X - M.row(0)*X = 0 // (2.*(u - cu)/w - 1) * (M.block(3,0,1,3)*x + M(3,3)) - M.block(0,0,1,3)*x - M(0,3) = 0 // (2.*(u - cu)/w - 1) * (M.block(3,0,1,3)*x + M(3,3)) - M.block(0,0,1,3)*x = M(0,3) // ((2.*(u - cu)/w - 1) * M.block(3,0,1,3) - M.block(0,0,1,3))*x = M(0,3) - (2.*(u - cu)/w - 1)*M(3,3) Eigen::Matrix M = _M.template cast(); A.resize(2,3); A<< ((2.*(u - cu)/w - 1.) * M.block(3,0,1,3) - M.block(0,0,1,3)), ((2.*(v - cv)/h - 1.) * M.block(3,0,1,3) - M.block(1,0,1,3)); B.resize(2,1); B<< M(0,3) - (2.*(u - cu)/w - 1.)*M(3,3), M(1,3) - (2.*(v - cv)/h - 1.)*M(3,3); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template void igl::projection_constraint, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh template void igl::projection_constraint, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif