Beispiel #1
0
   void ImageViewManipulator::initializeToCurrentView()
   {
      if(m_scrollView)
      {
         //ossimDpt center  = m_scrollView->getInputBounds().midPoint();
         //m_centerPoint = center;

         m_fullResolutionScale = ossimDpt(1.0,1.0);

         ossimTypeNameVisitor visitor("ossimImageRenderer", true);
         m_scrollView->connectableObject()->accept(visitor);


         ossimConnectableObject* connectable = dynamic_cast<ossimConnectableObject*>(visitor.getObject());
         ossimViewInterface* geomSource = connectable?dynamic_cast<ossimViewInterface*>(connectable):0;
         ossimImageSource* is = connectable?dynamic_cast<ossimImageSource*>(connectable->getInput()):0;

         if(geomSource)
         {
            if(geomSource->getView())
            {
               m_obj = (ossimObject*)(geomSource->getView()->dup());
            }
         }
         if(!is)
         {
            visitor.reset();
            visitor.setTypeName("ossimImageHandler");
            m_scrollView->connectableObject()->accept(visitor);
            is = dynamic_cast<ossimImageSource*>(visitor.getObject());
         }
         bool affineFlag = isAffine();
         if(is)
         {
            ossim_uint32 nLevels = is->getNumberOfDecimationLevels();
            nLevels = nLevels?nLevels:1;
            ossim_float64 nLevelsPower2 = 1<<(nLevels-1);
            ossim_float64 zoomInFactor  = 1<<7;
            ossimRefPtr<ossimImageGeometry> geom = is->getImageGeometry();
            if(!affineFlag&&geom.valid()&&geom->getProjection())
            {
               m_fullResolutionScale = geom->getMetersPerPixel();
               m_fullResolutionScale.x = m_fullResolutionScale.y;
               m_scaleRange.m_min = m_fullResolutionScale.y*(1.0/zoomInFactor);
               m_scaleRange.m_max = m_fullResolutionScale.y*nLevelsPower2;
            }
            else
            {
               m_scaleRange.m_min =1.0/nLevelsPower2;
               m_scaleRange.m_max = zoomInFactor;
            }
         }
         setCommonCenter();
      }
   }
void Matrix4::decomposition(Vector3& position, Vector3& scale, Quaternion& orientation) const
{
    assert(isAffine());

    Matrix3 m3x3;
    extract3x3Matrix(m3x3);

    Matrix3 matQ;
    Vector3 vecU;
    m3x3.QDUDecomposition(matQ, scale, vecU);

    orientation = Quaternion(matQ);
    position = Vector3(m[0][3], m[1][3], m[2][3]);
}
Beispiel #3
0
//-----------------------------------------------------------------------
void DiMat4::decomposition(DiVec3& position, DiVec3& scale, DiQuat& orientation) const
{
    DI_ASSERT(isAffine());

    DiMat3 m3x3;
    extract3x3Matrix(m3x3);

    DiMat3 matQ;
    DiVec3 vecU;
    m3x3.QDUDecomposition( matQ, scale, vecU ); 

    orientation = DiQuat( matQ );
    position = DiVec3( m[0][3], m[1][3], m[2][3] );
}
Matrix4 Matrix4::inverseAffine() const {
#ifdef _DEBUG
    assert(isAffine());
    // add error code...
#endif
    float m10 = m_fm[1][0], m11 = m_fm[1][1], m12 = m_fm[1][2];
    float m20 = m_fm[2][0], m21 = m_fm[2][1], m22 = m_fm[2][2];

    float t00 = m22 * m11 - m21 * m12;
    float t10 = m20 * m12 - m22 * m10;
    float t20 = m21 * m10 - m20 * m11;

    float m00 = m_fm[0][0], m01 = m_fm[0][1], m02 = m_fm[0][2];

    float invDet = 1 / (m00 * t00 + m01 * t10 + m02 * t20);

    t00 *= invDet;
    t10 *= invDet;
    t20 *= invDet;

    m00 *= invDet;
    m01 *= invDet;
    m02 *= invDet;

    float r00 = t00;
    float r01 = m02 * m21 - m01 * m22;
    float r02 = m01 * m12 - m02 * m11;

    float r10 = t10;
    float r11 = m00 * m22 - m02 * m20;
    float r12 = m02 * m10 - m00 * m12;

    float r20 = t20;
    float r21 = m01 * m20 - m00 * m21;
    float r22 = m00 * m11 - m01 * m10;

    float m03 = m_fm[0][3], m13 = m_fm[1][3], m23 = m_fm[2][3];

    float r03 = - (r00 * m03 + r01 * m13 + r02 * m23);
    float r13 = - (r10 * m03 + r11 * m13 + r12 * m23);
    float r23 = - (r20 * m03 + r21 * m13 + r22 * m23);

    return Matrix4(
               r00, r01, r02, r03,
               r10, r11, r12, r13,
               r20, r21, r22, r23,
               0,   0,   0,   1);

} //#### end inversAffine
Beispiel #5
0
//-----------------------------------------------------------------------
Matrix4 Matrix4::inverseAffine(void) const
{
    assert(isAffine());

    Real m10 = m[1][0], m11 = m[1][1], m12 = m[1][2];
    Real m20 = m[2][0], m21 = m[2][1], m22 = m[2][2];

    Real t00 = m22 * m11 - m21 * m12;
    Real t10 = m20 * m12 - m22 * m10;
    Real t20 = m21 * m10 - m20 * m11;

    Real m00 = m[0][0], m01 = m[0][1], m02 = m[0][2];

    Real invDet = 1 / (m00 * t00 + m01 * t10 + m02 * t20);

    t00 *= invDet;
    t10 *= invDet;
    t20 *= invDet;

    m00 *= invDet;
    m01 *= invDet;
    m02 *= invDet;

    Real r00 = t00;
    Real r01 = m02 * m21 - m01 * m22;
    Real r02 = m01 * m12 - m02 * m11;

    Real r10 = t10;
    Real r11 = m00 * m22 - m02 * m20;
    Real r12 = m02 * m10 - m00 * m12;

    Real r20 = t20;
    Real r21 = m01 * m20 - m00 * m21;
    Real r22 = m00 * m11 - m01 * m10;

    Real m03 = m[0][3], m13 = m[1][3], m23 = m[2][3];

    Real r03 = - (r00 * m03 + r01 * m13 + r02 * m23);
    Real r13 = - (r10 * m03 + r11 * m13 + r12 * m23);
    Real r23 = - (r20 * m03 + r21 * m13 + r22 * m23);

    return Matrix4(
               r00, r01, r02, r03,
               r10, r11, r12, r13,
               r20, r21, r22, r23,
               0,   0,   0,   1);
}
Beispiel #6
0
//-----------------------------------------------------------------------
DiMat4 DiMat4::inverseAffine(void) const
{
    DI_ASSERT(isAffine());

    float m10 = m[1][0], m11 = m[1][1], m12 = m[1][2];
    float m20 = m[2][0], m21 = m[2][1], m22 = m[2][2];

    float t00 = m22 * m11 - m21 * m12;
    float t10 = m20 * m12 - m22 * m10;
    float t20 = m21 * m10 - m20 * m11;

    float m00 = m[0][0], m01 = m[0][1], m02 = m[0][2];

    float invDet = 1 / (m00 * t00 + m01 * t10 + m02 * t20);

    t00 *= invDet; t10 *= invDet; t20 *= invDet;

    m00 *= invDet; m01 *= invDet; m02 *= invDet;

    float r00 = t00;
    float r01 = m02 * m21 - m01 * m22;
    float r02 = m01 * m12 - m02 * m11;

    float r10 = t10;
    float r11 = m00 * m22 - m02 * m20;
    float r12 = m02 * m10 - m00 * m12;

    float r20 = t20;
    float r21 = m01 * m20 - m00 * m21;
    float r22 = m00 * m11 - m01 * m10;

    float m03 = m[0][3], m13 = m[1][3], m23 = m[2][3];

    float r03 = - (r00 * m03 + r01 * m13 + r02 * m23);
    float r13 = - (r10 * m03 + r11 * m13 + r12 * m23);
    float r23 = - (r20 * m03 + r21 * m13 + r22 * m23);

    return DiMat4(
        r00, r01, r02, r03,
        r10, r11, r12, r13,
        r20, r21, r22, r23,
          0,   0,   0,   1);
}