I seem to have problem with a silly problem as storing a the absolute value of Eigen vector3d.
I want to compute the pow(p.cwiseAbs(),2)
but since p.cwiseAbs()
isn't a double, the function call doesn't work. i then tried to store it into a variable .. but somehow it doesn't seem possible..
ex.
double p_abs = p.cwiseAbs();
Error message:
error: cannot convert ‘const Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs_op<double>, const Eigen::Matrix<double, 3, 1> >’ to ‘double’ in initialization
double p_abs = p.cwiseAbs();
How do i compute the pow(..,2)
of the absolute value of the vector?.
The expression i am trying to write into code is :
The expression i am trying to code is the one explained by the first answer on this post.
To answer the original question "how-do-i-compute-the-closest-points-on-a-sphere-given-a-point-outside-the-sphere" using Eigen:
Vector3d center, P, Q;
double radius;
Q = center + radius * (P-center).normalized()