Commit 525a3ee6 authored by Syoyo Fujita's avatar Syoyo Fujita

Add assertion to avoid passing negative value to sqrt().

parent 2d76f2f9
......@@ -452,9 +452,10 @@ Float RealisticCamera::FocusThickLens(Float focusDistance) {
// Compute translation of lens, _delta_, to focus at _focusDistance_
Float f = fz[0] - pz[0];
Float z = -focusDistance;
Float c = (pz[1] - z - pz[0]) * (pz[1] - z * 4 * f - pz[0]);
CHECK_GT(c, 0) << "Coefficient must be positive. It looks focusDistance: " << focusDistance << " is too short for a given lenses configuration";
Float delta =
0.5f * (pz[1] - z + pz[0] -
std::sqrt((pz[1] - z - pz[0]) * (pz[1] - z - 4 * f - pz[0])));
0.5f * (pz[1] - z + pz[0] - std::sqrt(c));
return elementInterfaces.back().thickness + delta;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment