PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 318 of file rt_raster.c.

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

Referenced by rt_raster_set_phys_params().

Here is the caller graph for this function: