/***********************************************************************//** * @brief Initialise image header * * Initialises the image header by setting the default header cards. This * method requires the members m_bitpix, m_naxis, and m_naxes to be set * previously. ***************************************************************************/ void GFitsImage::init_image_header(void) { // Set image header keywords m_header.append(GFitsHeaderCard("XTENSION", "IMAGE ", "IMAGE extension")); m_header.append(GFitsHeaderCard("BITPIX", bitpix(), "number of bits per data pixel")); m_header.append(GFitsHeaderCard("NAXIS", naxis(), "number of data axes")); for (int i = 0; i < naxis(); ++i) { std::ostringstream s_key; std::ostringstream s_comment; s_key << "NAXIS" << (i+1); s_comment << "length of data axis " << (i+1); m_header.append(GFitsHeaderCard(s_key.str(), naxes(i), s_comment.str())); } m_header.append(GFitsHeaderCard("PCOUNT", 0, "required keyword; must = 0")); m_header.append(GFitsHeaderCard("GCOUNT", 1, "required keyword; must = 1")); // Return return; }
/***********************************************************************//** * @brief Return dimension of an image axis * * @param[in] axis Image axis [0,...,naxis()-1]. * * @exception GException::out_of_range * Image axis not valid. ***************************************************************************/ int GFitsImage::naxes(const int& axis) const { // Check if axis is within the range #if defined(G_RANGE_CHECK) if (axis < 0 || axis >= naxis()) { throw GException::out_of_range(G_NAXES, "Image axis", axis, naxis()); } #endif // Get axis dimension int dim = m_naxes[axis]; // Return axis dimension return dim; }
/***********************************************************************//** * @brief Print column information * * @param[in] chatter Chattiness. * @return String containing column information. * * @todo Format and cfitsio information is mainly for debugging. This could * be vanish in a more stable version of the code, or it could be compiled * in conditionally using a debug option. ***************************************************************************/ std::string GFitsImage::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GFitsImage ==="); // Append HDU information result.append("\n"+print_hdu(chatter)); // Append image dimensions result.append("\n"+gammalib::parformat("Image type")); result.append(typecode(type())); result.append("\n"+gammalib::parformat("Number of dimensions")); result.append(gammalib::str(naxis())); result.append("\n"+gammalib::parformat("Number of image pixels")); result.append(gammalib::str(npix())); for (int i = 0; i < naxis(); ++i) { result.append("\n"+gammalib::parformat("Number of bins in "+gammalib::str(i))); result.append(gammalib::str(naxes(i))); } // NORMAL: Append header information if (chatter >= NORMAL) { result.append(+"\n"+m_header.print(gammalib::reduce(chatter))); } } // endif: chatter was not silent // Return result return result; }
void rotArcballTrans(Matrix4fT &matfT, const Vector3d &axis, double angle) { Matrix4f rot = Matrix4f::IDENTITY; Vector3d naxis(axis); naxis.normalize(); rot.rotate(angle, naxis); Matrix4f matf; typedef Matrix4f::iterator mIt; for (mIt it = matf.begin(); it!=matf.end(); ++it){ uint i = it - matf.begin(); *it = matfT.M[i]; } matf = rot * matf; for (mIt it = matf.begin(); it!=matf.end(); ++it){ uint i = it - matf.begin(); matfT.M[i] = *it; } }
void SJRotation::get_value(SJMat3 &matrix) const { SJVec3 naxis(quaternion[0], quaternion[1], quaternion[2]); naxis.normalize(); float radians = deg2rad * quaternion[3]; // float degsTemp = (float)fmod(quaternion[3], 360.0); // if(degsTemp < 0.f) degsTemp += 360.0f; // float radians = M_PI * degsTemp / 180.0f; float sint = sinf(radians); float cost = cosf(radians); float ux = naxis[0]; float ux2 = ux * ux; float uy = naxis[1]; float uy2 = uy * uy; float uz = naxis[2]; float uz2 = uz * uz; matrix[0][0] = (float)(ux2 + cost * (1 - ux2)); matrix[0][1] = (float)(ux * uy * (1 - cost) - uz * sint); matrix[0][2] = (float)(uz * ux * (1 - cost) + uy * sint); matrix[0][3] = 0.f; matrix[1][0] = (float)(ux * uy * (1 - cost) + uz * sint); matrix[1][1] = (float)(uy2 + cost * (1 - uy2)); matrix[1][2] = (float)(uy * uz * (1 - cost) - ux * sint); matrix[1][3] = 0.f; matrix[2][0] = (float)(uz * ux * (1 - cost) - uy * sint); matrix[2][1] = (float)(uy * uz * (1 - cost) + ux * sint); matrix[2][2] = (float)(uz2 + cost * (1 - uz2)); matrix[2][3] = 0.0; matrix[3][0] = 0.0; matrix[3][1] = 0.0; matrix[3][2] = 0.0; matrix[3][3] = 1.f; }