Diff of /math.c[181a27] .. [91449a]  Maximize  Restore

Switch to side-by-side view

```--- a/math.c
+++ b/math.c
@@ -1063,7 +1063,7 @@

Image * setup_panini_general(struct MakeParams* pmp)
{	int  i;
-    double s,t,d,a,v, vl[2];
+    double s,t,d,a,b,v, vl[2];
Image * ppg = NULL;

// Only act if it is panini_general
@@ -1075,7 +1075,7 @@
return NULL;

/* check number of precomputed param values */
-    if( ppg->precomputedCount == 5 )
+    if( ppg->precomputedCount == 7 )
return ppg;		// OK

/* default unspecified values to 0, giving
@@ -1091,31 +1091,31 @@
return NULL;
d = ppg->precomputedValue[0];

-  /* post max feasible half-FOV as angle and x value */
+  /* get max feasible half-FOVs */
if( !panini_general_maxVAs( d,
-								DEG_TO_RAD( 80 ),		// max projection angle
+								DEG_TO_RAD( 80 ),	// max projection angle
vl					// max view angles h, v
)
)
return 0;
-	a = vl[0];
+
+  // angle and coordinate limits
+	s = (d + 1) / (d + cos(a));
+	ppg->precomputedValue[3] = vl[0];	// max lambda
+	ppg->precomputedValue[4] = s * sin( vl[0] );	// max x
+	ppg->precomputedValue[5] = vl[1];	// max phi
+	ppg->precomputedValue[6] = s * tan( vl[1] );	// max y

// clip hFOV to feasible limit
v = 0.5 * DEG_TO_RAD( ppg->hfov );
-	if( v > a )
-		v = a;
-
-  // x coordinate limit
-	s = sin( a ) * (d + 1) / (d + cos(a));
-
-  // distance param
+	if( v > vl[0] )
+		v = vl[0];
+
+  // set distance param
t = sin(v) * (d+1) / (d + cos(v));
pmp->distance = 0.5 * ppg->width / t;

-	ppg->precomputedValue[3] = a;	// max lambda
-	ppg->precomputedValue[4] = s;	// max x
-
-	ppg->precomputedCount = 5;
+	ppg->precomputedCount = 7;
return ppg;
}

@@ -1134,9 +1134,12 @@
y = y_dest/distance;
x = x_dest/distance;

-  // fail if outside feasible FOV
-	if( fabs(x) > ppg->precomputedValue[4] )
-		return 0;
+  // fail if outside max image
+/*	if(  fabs(x) > ppg->precomputedValue[4]
+	  || fabs(y) > ppg->precomputedValue[6]
+	  )
+	  return 0;
+*/
// call mapping fn
if( !panini_general_toSphere( &lambda, &phi, x, y,
ppg->precomputedValue[0],
@@ -1145,7 +1148,7 @@
)
return 0;

-	*lambda_src = lambda * distance;
+ 	*lambda_src = lambda * distance;
*phi_src = phi * distance;

return TRUE;
@@ -1172,9 +1175,11 @@
phi = phi_dest/distance;

// fail if outside feasible FOV
-	if( fabs(lambda) > ppg->precomputedValue[3] )
-		return 0;
-
+/*	if(  fabs(lambda) > ppg->precomputedValue[3]
+	  || fabs(phi) > ppg->precomputedValue[5]
+	  )
+	  return 0;
+*/
// call mapping fn
if( !panini_general_toPlane( lambda, phi, &x, &y,
ppg->precomputedValue[0],
@@ -1183,6 +1188,12 @@
)
return 0;

+  // fail if coords outside max image (needed for squeeze)
+/*	if(  fabs(x) > ppg->precomputedValue[4]
+	  || fabs(y) > ppg->precomputedValue[6]
+	  )
+	  return 0;
+*/
*y_src = distance * y;
*x_src = distance * x;
return 1;
```