
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dX.v))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_0) (* t_6 t_4))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dX_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_0;
} else {
tmp = t_6 * t_4;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dX_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_0); else tmp = Float32(t_6 * t_4); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dX_46_v; t_1 = floor(w) * dY_46_u; t_2 = floor(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dX.v))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_0) (* t_6 t_4))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dX_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_0;
} else {
tmp = t_6 * t_4;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dX_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_0); else tmp = Float32(t_6 * t_4); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dX_46_v; t_1 = floor(w) * dY_46_u; t_2 = floor(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* (floor w) dY.u))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* dX.v (floor h)))
(t_4 (pow (hypot (* dX.u (floor w)) t_3) 2.0)))
(if (>= t_4 t_2)
(/ t_3 (sqrt (fmax t_4 t_2)))
(/ dY.v (/ (sqrt (fmax t_4 (pow (hypot t_1 t_0) 2.0))) (floor h))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dY_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = powf(hypotf(t_0, t_1), 2.0f);
float t_3 = dX_46_v * floorf(h);
float t_4 = powf(hypotf((dX_46_u * floorf(w)), t_3), 2.0f);
float tmp;
if (t_4 >= t_2) {
tmp = t_3 / sqrtf(fmaxf(t_4, t_2));
} else {
tmp = dY_46_v / (sqrtf(fmaxf(t_4, powf(hypotf(t_1, t_0), 2.0f))) / floorf(h));
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dY_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = hypot(t_0, t_1) ^ Float32(2.0) t_3 = Float32(dX_46_v * floor(h)) t_4 = hypot(Float32(dX_46_u * floor(w)), t_3) ^ Float32(2.0) tmp = Float32(0.0) if (t_4 >= t_2) tmp = Float32(t_3 / sqrt(((t_4 != t_4) ? t_2 : ((t_2 != t_2) ? t_4 : max(t_4, t_2))))); else tmp = Float32(dY_46_v / Float32(sqrt(((t_4 != t_4) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? t_4 : max(t_4, (hypot(t_1, t_0) ^ Float32(2.0)))))) / floor(h))); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dY_46_v; t_1 = floor(w) * dY_46_u; t_2 = hypot(t_0, t_1) ^ single(2.0); t_3 = dX_46_v * floor(h); t_4 = hypot((dX_46_u * floor(w)), t_3) ^ single(2.0); tmp = single(0.0); if (t_4 >= t_2) tmp = t_3 / sqrt(max(t_4, t_2)); else tmp = dY_46_v / (sqrt(max(t_4, (hypot(t_1, t_0) ^ single(2.0)))) / floor(h)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_4 := {\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, t\_3\right)\right)}^{2}\\
\mathbf{if}\;t\_4 \geq t\_2:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left(t\_4, t\_2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{dY.v}{\frac{\sqrt{\mathsf{max}\left(t\_4, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}{\left\lfloorh\right\rfloor}}\\
\end{array}
\end{array}
Initial program 75.6%
Simplified75.8%
Applied egg-rr61.2%
sub-neg61.2%
metadata-eval61.2%
+-commutative61.2%
log1p-undefine61.2%
rem-exp-log61.6%
associate-+r+75.7%
Simplified75.9%
Taylor expanded in w around 0 75.9%
Simplified76.0%
Taylor expanded in w around 0 76.0%
Simplified76.0%
Final simplification76.0%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.u (floor w)))
(t_1 (* (floor h) dY.v))
(t_2 (* (floor w) dY.u))
(t_3 (pow (hypot t_1 t_2) 2.0))
(t_4 (* dX.v (floor h)))
(t_5 (pow (hypot t_0 t_4) 2.0))
(t_6
(/ dY.v (/ (sqrt (fmax t_5 (pow (hypot t_2 t_1) 2.0))) (floor h))))
(t_7 (/ t_4 (sqrt (fmax t_5 t_3)))))
(if (<= dX.u 50.0)
(if (>= (pow t_4 2.0) t_3) t_7 t_6)
(if (>= (pow t_0 2.0) t_3) t_7 t_6))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = dX_46_u * floorf(w);
float t_1 = floorf(h) * dY_46_v;
float t_2 = floorf(w) * dY_46_u;
float t_3 = powf(hypotf(t_1, t_2), 2.0f);
float t_4 = dX_46_v * floorf(h);
float t_5 = powf(hypotf(t_0, t_4), 2.0f);
float t_6 = dY_46_v / (sqrtf(fmaxf(t_5, powf(hypotf(t_2, t_1), 2.0f))) / floorf(h));
float t_7 = t_4 / sqrtf(fmaxf(t_5, t_3));
float tmp_1;
if (dX_46_u <= 50.0f) {
float tmp_2;
if (powf(t_4, 2.0f) >= t_3) {
tmp_2 = t_7;
} else {
tmp_2 = t_6;
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_3) {
tmp_1 = t_7;
} else {
tmp_1 = t_6;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_u * floor(w)) t_1 = Float32(floor(h) * dY_46_v) t_2 = Float32(floor(w) * dY_46_u) t_3 = hypot(t_1, t_2) ^ Float32(2.0) t_4 = Float32(dX_46_v * floor(h)) t_5 = hypot(t_0, t_4) ^ Float32(2.0) t_6 = Float32(dY_46_v / Float32(sqrt(((t_5 != t_5) ? (hypot(t_2, t_1) ^ Float32(2.0)) : (((hypot(t_2, t_1) ^ Float32(2.0)) != (hypot(t_2, t_1) ^ Float32(2.0))) ? t_5 : max(t_5, (hypot(t_2, t_1) ^ Float32(2.0)))))) / floor(h))) t_7 = Float32(t_4 / sqrt(((t_5 != t_5) ? t_3 : ((t_3 != t_3) ? t_5 : max(t_5, t_3))))) tmp_1 = Float32(0.0) if (dX_46_u <= Float32(50.0)) tmp_2 = Float32(0.0) if ((t_4 ^ Float32(2.0)) >= t_3) tmp_2 = t_7; else tmp_2 = t_6; end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_3) tmp_1 = t_7; else tmp_1 = t_6; end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = dX_46_u * floor(w); t_1 = floor(h) * dY_46_v; t_2 = floor(w) * dY_46_u; t_3 = hypot(t_1, t_2) ^ single(2.0); t_4 = dX_46_v * floor(h); t_5 = hypot(t_0, t_4) ^ single(2.0); t_6 = dY_46_v / (sqrt(max(t_5, (hypot(t_2, t_1) ^ single(2.0)))) / floor(h)); t_7 = t_4 / sqrt(max(t_5, t_3)); tmp_2 = single(0.0); if (dX_46_u <= single(50.0)) tmp_3 = single(0.0); if ((t_4 ^ single(2.0)) >= t_3) tmp_3 = t_7; else tmp_3 = t_6; end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= t_3) tmp_2 = t_7; else tmp_2 = t_6; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := {\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}\\
t_4 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_5 := {\left(\mathsf{hypot}\left(t\_0, t\_4\right)\right)}^{2}\\
t_6 := \frac{dY.v}{\frac{\sqrt{\mathsf{max}\left(t\_5, {\left(\mathsf{hypot}\left(t\_2, t\_1\right)\right)}^{2}\right)}}{\left\lfloorh\right\rfloor}}\\
t_7 := \frac{t\_4}{\sqrt{\mathsf{max}\left(t\_5, t\_3\right)}}\\
\mathbf{if}\;dX.u \leq 50:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_4}^{2} \geq t\_3:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;t\_6\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_3:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;t\_6\\
\end{array}
\end{array}
if dX.u < 50Initial program 75.5%
Simplified75.7%
Applied egg-rr58.3%
sub-neg58.3%
metadata-eval58.3%
+-commutative58.3%
log1p-undefine58.4%
rem-exp-log58.9%
associate-+r+75.6%
Simplified75.7%
Taylor expanded in w around 0 75.8%
Simplified75.8%
Taylor expanded in w around 0 75.8%
Simplified75.8%
Taylor expanded in dX.u around 0 68.5%
unpow268.5%
unpow268.5%
swap-sqr68.5%
unpow268.5%
Simplified68.5%
if 50 < dX.u Initial program 76.0%
Simplified76.2%
Applied egg-rr68.7%
sub-neg68.7%
metadata-eval68.7%
+-commutative68.7%
log1p-undefine68.8%
rem-exp-log68.8%
associate-+r+76.0%
Simplified76.3%
Taylor expanded in w around 0 76.3%
Simplified76.3%
Taylor expanded in w around 0 76.3%
Simplified76.3%
Taylor expanded in dX.u around inf 73.8%
unpow273.8%
unpow273.8%
swap-sqr73.8%
unpow273.8%
Simplified73.8%
Final simplification69.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* (floor w) dY.u))
(t_2 (* dX.v (floor h)))
(t_3 (* dX.u (floor w)))
(t_4 (pow (hypot t_3 t_2) 2.0))
(t_5 (pow (hypot t_0 t_1) 2.0)))
(if (>= (pow t_3 2.0) t_5)
(/ t_2 (sqrt (fmax t_4 t_5)))
(/ dY.v (/ (sqrt (fmax t_4 (pow (hypot t_1 t_0) 2.0))) (floor h))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
float t_0 = floorf(h) * dY_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = dX_46_v * floorf(h);
float t_3 = dX_46_u * floorf(w);
float t_4 = powf(hypotf(t_3, t_2), 2.0f);
float t_5 = powf(hypotf(t_0, t_1), 2.0f);
float tmp;
if (powf(t_3, 2.0f) >= t_5) {
tmp = t_2 / sqrtf(fmaxf(t_4, t_5));
} else {
tmp = dY_46_v / (sqrtf(fmaxf(t_4, powf(hypotf(t_1, t_0), 2.0f))) / floorf(h));
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(h) * dY_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(dX_46_v * floor(h)) t_3 = Float32(dX_46_u * floor(w)) t_4 = hypot(t_3, t_2) ^ Float32(2.0) t_5 = hypot(t_0, t_1) ^ Float32(2.0) tmp = Float32(0.0) if ((t_3 ^ Float32(2.0)) >= t_5) tmp = Float32(t_2 / sqrt(((t_4 != t_4) ? t_5 : ((t_5 != t_5) ? t_4 : max(t_4, t_5))))); else tmp = Float32(dY_46_v / Float32(sqrt(((t_4 != t_4) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? t_4 : max(t_4, (hypot(t_1, t_0) ^ Float32(2.0)))))) / floor(h))); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(h) * dY_46_v; t_1 = floor(w) * dY_46_u; t_2 = dX_46_v * floor(h); t_3 = dX_46_u * floor(w); t_4 = hypot(t_3, t_2) ^ single(2.0); t_5 = hypot(t_0, t_1) ^ single(2.0); tmp = single(0.0); if ((t_3 ^ single(2.0)) >= t_5) tmp = t_2 / sqrt(max(t_4, t_5)); else tmp = dY_46_v / (sqrt(max(t_4, (hypot(t_1, t_0) ^ single(2.0)))) / floor(h)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := {\left(\mathsf{hypot}\left(t\_3, t\_2\right)\right)}^{2}\\
t_5 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
\mathbf{if}\;{t\_3}^{2} \geq t\_5:\\
\;\;\;\;\frac{t\_2}{\sqrt{\mathsf{max}\left(t\_4, t\_5\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{dY.v}{\frac{\sqrt{\mathsf{max}\left(t\_4, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}{\left\lfloorh\right\rfloor}}\\
\end{array}
\end{array}
Initial program 75.6%
Simplified75.8%
Applied egg-rr61.2%
sub-neg61.2%
metadata-eval61.2%
+-commutative61.2%
log1p-undefine61.2%
rem-exp-log61.6%
associate-+r+75.7%
Simplified75.9%
Taylor expanded in w around 0 75.9%
Simplified76.0%
Taylor expanded in w around 0 76.0%
Simplified76.0%
Taylor expanded in dX.u around inf 67.8%
unpow267.8%
unpow267.8%
swap-sqr67.8%
unpow267.8%
Simplified67.8%
Final simplification67.8%
herbie shell --seed 2024076
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:name "Anisotropic x16 LOD (line direction, v)"
:precision binary32
:pre (and (and (and (and (and (and (and (<= 1.0 w) (<= w 16384.0)) (and (<= 1.0 h) (<= h 16384.0))) (and (<= 1e-20 (fabs dX.u)) (<= (fabs dX.u) 1e+20))) (and (<= 1e-20 (fabs dX.v)) (<= (fabs dX.v) 1e+20))) (and (<= 1e-20 (fabs dY.u)) (<= (fabs dY.u) 1e+20))) (and (<= 1e-20 (fabs dY.v)) (<= (fabs dY.v) 1e+20))) (== maxAniso 16.0))
(if (>= (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))) (* (/ 1.0 (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))))) (* (floor h) dX.v)) (* (/ 1.0 (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))))) (* (floor h) dY.v))))