bool WritePfm(const ei::Vec4* _data, const ei::IVec2& _size, const std::string& _filename, std::uint32_t _divisor) { std::ofstream file(_filename.c_str(), std::ios::binary); if(!file.bad() && !file.fail()) { file.write("PF\n", sizeof(char) * 3); file << _size.x << " " << _size.y << "\n"; file.write("-1.000000\n", sizeof(char) * 10); const ei::Vec4* v = _data; for (int y = 0; y < _size.y; ++y) { for (int x = 0; x < _size.x; ++x) { ei::Vec3 outV(v->x / _divisor, v->y / _divisor, v->z / _divisor); file.write(reinterpret_cast<const char*>(&outV), sizeof(float) * 3); ++v; } } return true; } else { LOG_ERROR("Error writing hdr image to " + _filename); return false; } }
gpstk::Vector<double> RACRotation::convertToRAC( const gpstk::Vector<double>& inV ) { gpstk::Vector<double> outV(3); /* My goal was to use the following statement. outV = this * inV; However, for some reason, gcc refuses to recognize RACRotation as a Matrix subclass. Therefore, I've incorporated the matrix multiply as a temporary kludge. */ if (inV.size()!=3) { gpstk::Exception e("Incompatible dimensions for Vector"); GPSTK_THROW(e); } size_t i, j; for (i = 0; i < 3; i++) { outV[i] = 0; for (j = 0; j < 3; j++) { double temp = (*this)(i,j) * inV[j]; outV[i] += temp; } } /* end kludge */ return(outV); }
gpstk::Vector<double> ENUUtil::convertToENU( const gpstk::Vector<double>& inV ) const { gpstk::Vector<double> outV(3); if (inV.size()!=3) { gpstk::Exception e("Incompatible dimensions for Vector"); GPSTK_THROW(e); } outV = rotMat * inV; return(outV); }
/** * \param v The vector to pre-multiply with this transformation. * * Applies this transformation to the specified vector \a v. This is the equivalent * of multiplying the vector by a 4x4 affine transformation matrix. The order of * operations is scale, rotate (pre-multiply with a rotation matrix), then translate. * * \sa applyInverse */ Vector3f Transformation::apply(const Vector3f& v) const { if (m_isIdentity) { return v; } Vector3f outV(v); outV.x() *= m_scale.x(); outV.y() *= m_scale.y(); outV.z() *= m_scale.z(); outV = m_rotation * outV; outV += m_translation; return outV; }