PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rt_raster_calc_gt_coeff()

int rt_raster_calc_gt_coeff ( double  i_mag,
double  j_mag,
double  theta_i,
double  theta_ij,
double *  xscale,
double *  xskew,
double *  yskew,
double *  yscale 
)

Calculates the coefficients of a geotransform given the physically significant parameters describing the transform.

Will fail if any of the result pointers is NULL, or if theta_ij has an illegal value (0 or PI).

Parameters
i_magsize of a pixel along the transformed i axis
j_magsize of a pixel along the transformed j axis
theta_iangle by which the raster is rotated (radians positive clockwise)
theta_ijangle from transformed i axis to transformed j axis (radians positive counterclockwise)
xscalegeotransform coefficient o_11
xskewgeotransform coefficient o_12
yskewgeotransform coefficient o_21
yscalegeotransform coefficient o_22
Returns
1 if the calculation succeeded, 0 if error.

Definition at line 314 of file rt_raster.c.

Referenced by rt_raster_set_phys_params().

316 {
317  double f ; /* reflection flag 1.0 or -1.0 */
318  double k_i ; /* shearing coefficient */
319  double s_i, s_j ; /* scaling coefficients */
320  double cos_theta_i, sin_theta_i ;
321 
322  if ( (xscale==NULL) || (xskew==NULL) || (yskew==NULL) || (yscale==NULL)) {
323  return 0;
324  }
325 
326  if ( (theta_ij == 0.0) || (theta_ij == M_PI)) {
327  return 0;
328  }
329 
330  /* Reflection across the i axis */
331  f=1.0 ;
332  if (theta_ij < 0) {
333  f = -1.0;
334  }
335 
336  /* scaling along i axis */
337  s_i = i_mag ;
338 
339  /* shearing parallel to i axis */
340  k_i = tan(f*M_PI_2 - theta_ij) ;
341 
342  /* scaling along j axis */
343  s_j = j_mag / (sqrt(k_i*k_i + 1)) ;
344 
345  /* putting it altogether */
346  cos_theta_i = cos(theta_i) ;
347  sin_theta_i = sin(theta_i) ;
348  *xscale = s_i * cos_theta_i ;
349  *xskew = k_i * s_j * f * cos_theta_i + s_j * f * sin_theta_i ;
350  *yskew = -s_i * sin_theta_i ;
351  *yscale = -k_i * s_j * f * sin_theta_i + s_j * f * cos_theta_i ;
352  return 1;
353 }
Here is the caller graph for this function: