skyprojection.cc
// Computes the size of the output dimensions by comparing pixel distances
// along east and west.
Computes the size of the output dimensions by comparing pixel distances
along east and west.
Computes the size of the output dimensions by comparing pixel distances along east and west .
void SkyProjection::DetermineProjectedSize(void) {
  const Point &ra_min = bounding_box_.ra_min();
  const Point &ra_max = bounding_box_.ra_max();
  const Point &dec_min = bounding_box_.dec_min();
  int east_side_len = Round(ra_max.DistanceXY(dec_min));
  int north_side_len = Round(ra_min.DistanceXY(dec_min));
  double cos_theta = (ra_max.ra - dec_min.ra) /
                     (ra_max.DistanceRaDec(dec_min) + TINY_FLOAT_VALUE);
  double theta = acos(cos_theta);
  double theta_degrees = theta * (180.0 / PI);
  if (fabs(theta_degrees - 90.0) < TINY_THETA_VALUE ||
      fabs(theta_degrees - 270.0) < TINY_THETA_VALUE) {
    projected_width_ = image_->width();
    projected_height_ = image_->height();
  } else if (fabs(theta_degrees) < TINY_THETA_VALUE ||
             fabs(theta_degrees - 180.0) < TINY_THETA_VALUE) {
    projected_width_ = image_->height();
    projected_height_ = image_->width();
  } else {
    projected_width_ =
        Round(cos(theta) * east_side_len + sin(theta) * north_side_len);
    projected_height_ =
        Round(sin(theta) * east_side_len + cos(theta) * north_side_len);
  }
  assert(projected_width_ > 0);
  assert(projected_height_ > 0);
}
void SkyProjection :: DetermineProjectedSize ( void ) { const Point & ra_min = bounding_box_ . ra_min ( ) ; const Point & ra_max = bounding_box_ . ra_max ( ) ; const Point & dec_min = bounding_box_ . dec_min ( ) ; int east_side_len = Round ( ra_max . DistanceXY ( dec_min ) ) ; int north_side_len = Round ( ra_min . DistanceXY ( dec_min ) ) ; double cos_theta = ( ra_max . ra - dec_min . ra ) / ( ra_max . DistanceRaDec ( dec_min ) + TINY_FLOAT_VALUE ) ; double theta = acos ( cos_theta ) ; double theta_degrees = theta * ( 180.0 / PI ) ; if ( fabs ( theta_degrees - 90.0 ) < TINY_THETA_VALUE || fabs ( theta_degrees - 270.0 ) < TINY_THETA_VALUE ) { projected_width_ = image_ -> width ( ) ; projected_height_ = image_ -> height ( ) ; } else if ( fabs ( theta_degrees ) < TINY_THETA_VALUE || fabs ( theta_degrees - 180.0 ) < TINY_THETA_VALUE ) { projected_width_ = image_ -> height ( ) ; projected_height_ = image_ -> width ( ) ; } else { projected_width_ = Round ( cos ( theta ) * east_side_len + sin ( theta ) * north_side_len ) ; projected_height_ = Round ( sin ( theta ) * east_side_len + cos ( theta ) * north_side_len ) ; } assert ( projected_width_ > 0 ) ; assert ( projected_height_ > 0 ) ; }
Computes the size of the output dimensions by comparing pixel distances
along east and west.
Computes the size of the output dimensions by comparing pixel distances along east and west .
// Determine the side lengths along north and east. // Compute the angle between east (x axis in new image) and the x axis in // the old image.  We need to guard against zero divisions as the // denominator will be 0 for theta = 0. // Determine the size of the output image.  This size is chosen so that the // original image remains the same dimensions within the projected image. // We must treat the cases of theta = 0, 90, 180, and 270 specially as one of // the sides will be 0 otherwise. // NB: This algorithm still has trouble near these angles as the side lengths // for east and north can be wrong in these cases.