Fixed division by zero case in SphericalProjector::mapForward

This commit is contained in:
Andrey Kamaev 2012-08-08 20:57:12 +04:00
parent 017abbd963
commit 0ceb9b6a00

@ -242,7 +242,8 @@ void SphericalProjector::mapForward(float x, float y, float &u, float &v)
float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8];
u = scale * atan2f(x_, z_);
v = scale * (static_cast<float>(CV_PI) - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)));
float w = y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_);
v = scale * (static_cast<float>(CV_PI) - acosf(w == w ? w : 0));
}