PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 5619 of file rt_api.c.

Referenced by rt_raster_set_phys_params().

5621 {
5622  double f ; /* reflection flag 1.0 or -1.0 */
5623  double k_i ; /* shearing coefficient */
5624  double s_i, s_j ; /* scaling coefficients */
5625  double cos_theta_i, sin_theta_i ;
5626 
5627  if ( (xscale==NULL) || (xskew==NULL) || (yskew==NULL) || (yscale==NULL)) {
5628  return 0;
5629  }
5630 
5631  if ( (theta_ij == 0.0) || (theta_ij == M_PI)) {
5632  return 0;
5633  }
5634 
5635  /* Reflection across the i axis */
5636  f=1.0 ;
5637  if (theta_ij < 0) {
5638  f = -1.0;
5639  }
5640 
5641  /* scaling along i axis */
5642  s_i = i_mag ;
5643 
5644  /* shearing parallel to i axis */
5645  k_i = tan(f*M_PI_2 - theta_ij) ;
5646 
5647  /* scaling along j axis */
5648  s_j = j_mag / (sqrt(k_i*k_i + 1)) ;
5649 
5650  /* putting it altogether */
5651  cos_theta_i = cos(theta_i) ;
5652  sin_theta_i = sin(theta_i) ;
5653  *xscale = s_i * cos_theta_i ;
5654  *xskew = k_i * s_j * f * cos_theta_i + s_j * f * sin_theta_i ;
5655  *yskew = -s_i * sin_theta_i ;
5656  *yscale = -k_i * s_j * f * sin_theta_i + s_j * f * cos_theta_i ;
5657  return 1;
5658 }

Here is the caller graph for this function: