我正在尝试获取我的光 vector ,数学公式为
float3 l_ik = p_light - focus / || p_light - focus ||
获取的值|| p_light - focus ||
使用了来自 cv 的 normalize()
函数然后我尝试简单地计算 A/||B||因此我试图将公式视为
A / B <=> A * B^(-1)
in c++:
float3 l_ik = (p_light - focus) * ( normalize(p_light,focus)^(-1))
这导致 'math::operator*(...)
中的 'operator^' 不匹配。这意味着这个运算符没有实现,或者什么?还是无法计算 vector ^(-1)
感谢任何帮助。
最佳答案
^ 是 C++ 中的“异或”运算符,不是您所期望的。 pow(some_mat, number);
似乎更合适
normalize() 也用于制作单位 vector ,并采用 src 和 dst Mat,而不是你可能想要 norm(p_light - focus);//差异的范数
(你是说 opengl,而不是 opencv 吗?)
[编辑]
昨天很瞎,你的公式只是单位长度(p_light - focus) vector ,所以:
Vec3f v = p_light - focus;
Vec3f l_ik = v / norm(v);
关于c++ - OpenCV光 vector 计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23617191/