Ejemplo n.º 1
0
inline void TAligner_SW<CQuery,CSubject>::x_PrintMatrix()
{
    cerr << "\x1b[31mNULL\t\x1b[32mIdentity\t\x1b[33mMismatch\t\x1b[34mInsertion\t\x1b[35mDeletion\t\x1b[36mOTHER\x1b[0m\n";
    cerr << string(78,'=') << endl;
    for( int q = -1; q < (int)((*m_matrix)[0].size() - 1); ++q ) {
        for( int s = -1; s < (int)((*m_matrix)[0].size() - 1); ++s ) {
            if( s >= 0 ) cerr << "\t";
            switch( GetMatrix( q, s, false ).second ) {
            case eNull:
                cerr << "\x1b[31m";
                break;
            case eIdentity:
                cerr << "\x1b[32m";
                break;
            case eMismatch:
                cerr << "\x1b[33m";
                break;
            case eInsertion:
                cerr << "\x1b[34m";
                break;
            case eDeletion:
                cerr << "\x1b[35m";
                break;
            default:
                cerr << "\x1b[36m";
                break;
            }
            cerr << GetMatrix( q, s, false ).first << "\x1b[0m";
        }
        cerr << "\n";
    }
}
Ejemplo n.º 2
0
const CameraDesc& Camera::GetDesc() const
{
    m_desc.EyePosition = vector3f_t(GetMatrix(CoordType::Global) * vector4f_t(m_originalDesc.EyePosition, 1));
    m_desc.Direction = vector3f_t(GetMatrix(CoordType::Global) * GetMatrix(CoordType::Local) * vector4f_t(m_originalDesc.Direction, 0));
    m_desc.Up = vector3f_t(GetMatrix(CoordType::Global) * GetMatrix(CoordType::Local) * vector4f_t(m_originalDesc.Up, 0));
    return m_desc;
}
Ejemplo n.º 3
0
void MatrixMoveable::OnUpdateWorldMatrix(Matrix4& transform, int32 dirtyFlag)
{
	if (mParentMoveable != nullptr&&mParentMoveable->IsWorldMatrixDirty())
	{
		ForceSetWorldMatrix(GetMatrix()*(mParentMoveable->WorldMatrix()));
	}
	else
	{
		ForceSetWorldMatrix(GetMatrix());
	}
}
Ejemplo n.º 4
0
void TransformMoveable::OnUpdateWorldMatrix( Matrix4& transform )
{
	TransformMoveable* parent=GetParentMoveable();
	if (parent!=NULL&&parent->IsWorldMatrixDirty())
	{
		ForceSetWorldMatrix(GetMatrix()*(parent->GetWorldMatrix()));
	}
	else
	{
		ForceSetWorldMatrix(GetMatrix());
	}
}
Ejemplo n.º 5
0
wxSVGRect wxSVGVideoElement::GetBBox(wxSVG_COORDINATES coordinates) {
	wxSVGRect bbox = wxSVGRect(GetX().GetAnimVal(), GetY().GetAnimVal(), GetWidth().GetAnimVal(),
			GetHeight().GetAnimVal());
	if (coordinates != wxSVG_COORDINATES_USER)
		bbox.MatrixTransform(GetMatrix(coordinates));
	return bbox;
}
Ejemplo n.º 6
0
  void MGPreconditioner :: MgTest () const
  {
    cout << "Compute eigenvalues" << endl;
    const BaseMatrix & amat = GetAMatrix();
    const BaseMatrix & pre = GetMatrix();
    
    int eigenretval;
    
    EigenSystem eigen (amat, pre);
    eigen.SetPrecision(1e-30);
    eigen.SetMaxSteps(1000); 
    eigenretval = eigen.Calc();
    eigen.PrintEigenValues (*testout);
    (cout) << " Min Eigenvalue : "  << eigen.EigenValue(mgnumber) << endl; 
    (cout) << " Max Eigenvalue : " << eigen.MaxEigenValue() << endl; 
    (cout) << " Condition   " << eigen.MaxEigenValue()/eigen.EigenValue(mgnumber) << endl; 
    (*testout) << " Min Eigenvalue : "  << eigen.EigenValue(mgnumber) << endl; 
    (*testout) << " Max Eigenvalue : " << eigen.MaxEigenValue() << endl;
    (*testout) << " Condition   " << eigen.MaxEigenValue()/eigen.EigenValue(mgnumber) << endl;
    static ofstream condout (mgfile.c_str());

    // double cond;

    condout << bfa->GetFESpace()->GetNDof() << "\t" << bfa->GetFESpace()->GetOrder() << "\t" << eigen.EigenValue(mgnumber) << "\t" << eigen.MaxEigenValue() << "\t" 
	    << eigen.MaxEigenValue()/eigen.EigenValue(mgnumber) <<  "\t" << endl;
    
    if(testresult_ok) *testresult_ok = eigenretval;
    if(testresult_min) *testresult_min = eigen.EigenValue(mgnumber);
    if(testresult_max) *testresult_max = eigen.MaxEigenValue();

  }
Ejemplo n.º 7
0
/**
 @brief 바운딩박스를 계산해 돌려준다.
*/
XE::xRECT XLayerImage::GetBoundBox( const D3DXMATRIX& mParent ) const 
{
	// 이미지의 4귀퉁이를 이 매트릭스로 트랜스폼
	XSprite *pSpr = m_pSpriteCurr;
	if( pSpr ) {
		const D3DXVECTOR2 vAdj = pSpr->GetAdjust();
		const auto vSize = pSpr->GetSize();
		D3DXVECTOR2 vLT = vAdj;
		D3DXVECTOR2 vRT = D3DXVECTOR2( vAdj.x + vSize.w, vAdj.y );
		D3DXVECTOR2 vLB = D3DXVECTOR2( vAdj.x					, vAdj.y + vSize.h );
		D3DXVECTOR2 vRB = D3DXVECTOR2( vAdj.x + vSize.w, vAdj.y + vSize.h );
		XE::VEC2 vtLT, vtRT, vtLB, vtRB;
		D3DXVECTOR4 vResult;
		const auto mWorld = GetMatrix() * mParent;
		D3DXVec2Transform( &vResult, &vLT, &mWorld );	vtLT.Set( vResult.x, vResult.y );
		D3DXVec2Transform( &vResult, &vRT, &mWorld );	vtRT.Set( vResult.x, vResult.y );
		D3DXVec2Transform( &vResult, &vLB, &mWorld );	vtLB.Set( vResult.x, vResult.y );
		D3DXVec2Transform( &vResult, &vRB, &mWorld );	vtRB.Set( vResult.x, vResult.y );
		XE::xRECT rectBB;
		rectBB.UpdateBoundBox( vtLT );
		rectBB.UpdateBoundBox( vtRT );
		rectBB.UpdateBoundBox( vtLB );
		rectBB.UpdateBoundBox( vtRB );
		return rectBB;
	}
	return XE::xRECT();
}
Ejemplo n.º 8
0
void nuiSprite::GetSpritesAtPoint(float x, float y, std::vector<nuiSprite*>& rSprites)
{
  CheckValid();
  nuiVector ov(x, y, 0);
  nuiMatrix m;
  GetMatrix(m);
  m.Invert();
  nuiVector v = m * ov;
  x = v[0];
  y = v[1];
  
  const nuiSpriteAnimation* pAnim = mpSpriteDef->GetAnimation(mCurrentAnimation);
  const nuiSpriteFrame* pFrame = pAnim->GetFrame(ToBelow(mCurrentFrame));
  nuiRect dst(pFrame->GetRect());
  dst.Move(-pFrame->GetHandleX(), -pFrame->GetHandleY());
  
  if (dst.IsInside(x, y))
    rSprites.push_back(this);

  uint32 s = mpChildren.size();
  for (size_t i = 0; i < s; i++)
  {
    mpChildren[i]->GetSpritesAtPoint(x, y, rSprites);
  }
}
Ejemplo n.º 9
0
void nuiSprite::Draw(nuiDrawContext* pContext)
{
  CheckValid();
  nuiMatrix m;
  GetMatrix(m);
  pContext->PushMatrix();
  pContext->MultMatrix(m);
  
  const nuiSpriteAnimation* pAnim = mpSpriteDef->GetAnimation(mCurrentAnimation);
  const nuiSpriteFrame* pFrame = pAnim->GetFrame(ToBelow(mCurrentFrame));
  nuiRect src(pFrame->GetRect());
  nuiRect dst(src);
  dst.Move(-pFrame->GetHandleX(), -pFrame->GetHandleY());
  
  nuiTexture* pTex = pFrame->GetTexture();

  pContext->EnableBlending(true);
  pContext->SetBlendFunc(mBlendFunc);
  nuiColor c = mColor;
  c.Multiply(mAlpha);
  pContext->SetFillColor(c);
  pContext->SetTexture(pFrame->GetTexture());
  
  
  
  // #TEST Meeloo
  //dst.Grow(dst.GetWidth() * -.25, dst.GetHeight() * -.25);

  pContext->DrawImage(dst, src);
  
  pContext->PopMatrix();

  for (size_t i = 0; i < mpChildren.size(); i++)
    mpChildren[i]->Draw(pContext);
}
Ejemplo n.º 10
0
nuiMatrix nuiSprite::GetMatrix() const
{
  CheckValid();
  nuiMatrix m;
  GetMatrix(m);
  return m;
}
Ejemplo n.º 11
0
bool nuiSprite::IsMatrixIdentity() const
{
  CheckValid();
  nuiMatrix m;
  GetMatrix(m);
  return !mpMatrixNodes || m.IsIdentity();
}
Ejemplo n.º 12
0
void Inversion(FunctionCall fc)
{
	int i, j, index, exist = 0;
	Matrix a, c;
	char name[MAXSIZE_NAME] = {0};

	index = IndexMatrix(fc->name);
	if (index==-1)
	{
		index = cur_mat;
		mats[index] = (StrMatObject*)malloc(sizeof(StrMatObject));
		
		if (mats[index] == NULL)
		{
			printf("NewMatrix(): Could not allocate the new matrix\n");
			return;
		}

		for (i = 0; i < MAXSIZE_NAME; i++)
		{
			mats[index]->name[i] = fc->name[i];
			if (fc->name[i]=='\0') break;
		}
	}
	else exist = 1;
	
	j = 0;
	// searching for matrix name
	for (i = 0; i < MAXSIZE_NAME; i++)
	{
		name[j] = fc->args[i];
		if (name[j] == '\0') break;
		j++;
	}
	
	a = GetMatrix(name);
	if (a==NULL)
	{
		printf("\tMatrix %s Not Found\n", name);
		if (!exist) free(mats[index]);
		return;
	}
	
	c = invert(a);
	
	if (c==NULL)
	{
		printf("\tMatrix %s Not Invertible\n", name);
		if (!exist) free(mats[index]);
		return;
	}
	
	if (exist) deleteMatrix(mats[index]->mat);
	mats[index]->mat = c;
	
	// test: display the result
	displayMatrix(mats[index]->mat);
	
	if (!exist) cur_mat++;
}
Ejemplo n.º 13
0
already_AddRefed<SVGMatrix>
SVGMatrix::Translate(float x, float y)
{
  nsRefPtr<SVGMatrix> matrix =
    new SVGMatrix(gfxMatrix(GetMatrix()).Translate(gfxPoint(x, y)));
  return matrix.forget();
}
Ejemplo n.º 14
0
void CBurnBot::CollisionResponse(IBaseObject* pObj)
{
	int nType = pObj->GetID();

	Sphere tempSphere = pObj->GetSphere();
	D3DXVECTOR3 V = tempSphere.m_Center - this->GetSphere().m_Center;
	float Mag = D3DXVec3Length(&V);
	float Distance = tempSphere.m_Radius + GetSphere().m_Radius;
	float X = Distance/Mag + EPISILON;
	V = V * X;
	D3DXMATRIX tempMat = pObj->GetMatrix();
	if(nType == OBJ_TUNNEL)
		tempMat._43 *= 0.85f;
	D3DXMATRIX tempSetMat = GetMatrix();
	tempSetMat._41 = tempMat._41 - V.x;
	tempSetMat._43 = tempMat._43 - V.z;
	this->SetMatrix(tempSetMat);


	if( nType == OBJ_PLAYER )
	{
		if(!m_bCloseToTarget)
		{
			m_bCloseToTarget = true;
			m_fExplodeTimer = BURN_CHARGETIME;
			SetBeingHit(BURNEXPLODE);
			WwiseNS::PlaySFX(WwiseNS::EVENT_SOUND_BURNALERT);
			ChangeAnimation(0);
		}
	}
}
Ejemplo n.º 15
0
////////////////////////////////////////////////////////////
/// Draw the object into the specified window
////////////////////////////////////////////////////////////
void Drawable::Draw(RenderTarget& Target) const
{
    // Save the current modelview matrix and set the new one
    GLCheck(glMatrixMode(GL_MODELVIEW));
    GLCheck(glPushMatrix());
    GLCheck(glMultMatrixf(GetMatrix().Get4x4Elements()));

    // Setup alpha-blending
    if (myBlendMode == Blend::None)
    {
        GLCheck(glDisable(GL_BLEND));
    }
    else
    {
        GLCheck(glEnable(GL_BLEND));

        switch (myBlendMode)
        {
            case Blend::Alpha :    GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); break;
            case Blend::Add :      GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE));                 break;
            case Blend::Multiply : GLCheck(glBlendFunc(GL_DST_COLOR, GL_ZERO));                break;
            default :                                                                          break;
        }
    }

    // Set color
    GLCheck(glColor4f(myColor.r / 255.f, myColor.g / 255.f, myColor.b / 255.f, myColor.a / 255.f));

    // Let the derived class render the object geometry
    Render(Target);

    // Restore the previous modelview matrix
    GLCheck(glMatrixMode(GL_MODELVIEW));
    GLCheck(glPopMatrix());
}
Ejemplo n.º 16
0
void CObject::Explode()
{
    CVector pos = GetPos();
    pos.z += 0.5;
    CExplosion::AddExplosion(this, GetPlayerPed(-1), 9, pos, 100, 1, -1.0, 0);
    if (m_colDamageEffect == 202 || m_colDamageEffect == 200)
    {
        pos.z -= 1.0;
        ObjectDamage(10000.0f, pos, 0, GetPlayerPed(-1), 51);
    }
    else if (!m_disableFriction)
    {
        m_linearVelocity.z += 0.5;
        m_linearVelocity.x += (rand() - 128) * 0.000199999994947575;
        m_linearVelocity.y += (rand() - 128) * 0.000199999994947575;
        if (bIsStatic || bIsStaticWaitingForCollision)
        {
            SetIsStatic(false);
            AddToMovingList();
        }
    }
    if (m_objectInfo->fxType == 2)
    {
        CMatrix pos = GetMatrix();
        // to object space
        CVector fxObjPos = Multiply3x3(pos, m_objectInfo->fxOffset);
        fxObjPos += GetPos(); // to world space
        FxSystem_c *sys = FxManager.InitialiseFxSystem(m_objectInfo->fxSystem, fxObjPos, 0, 0);
        if (sys)
        {
            sys->Start();
        }
    }
}
Ejemplo n.º 17
0
already_AddRefed<SVGMatrix>
SVGMatrix::Rotate(float angle)
{
  nsRefPtr<SVGMatrix> matrix =
    new SVGMatrix(gfxMatrix(GetMatrix()).Rotate(angle*radPerDegree));
  return matrix.forget();
}
Ejemplo n.º 18
0
 // TODO: This could actually be strided?
 const char* NDMask::DataBuffer() const
 {
     // First make sure that the underlying matrix is on the right device
     auto matrix = GetMatrix();
     matrix->TransferToDeviceIfNotThere(AsCNTKImplDeviceId(m_device), true);
     return matrix->Data();
 }
Ejemplo n.º 19
0
    void NDMask::MaskSection(const std::vector<size_t>& sectionOffset, const NDShape& sectionShape)
    {
        // TODO: Implement batching of masking operation for masks residing on GPUs to avoid making
        // GPU invocations for each MaskSection call.

        if (sectionOffset.size() > m_maskShape.NumAxes())
            LogicError("NDMask::MaskSection: The sectionOffset cannot have dimensionality higher than the number of axes of 'this' mask");

        if (sectionShape.NumAxes() > m_maskShape.NumAxes())
            LogicError("NDMask::MaskSection: The section shape cannot have an axes count higher than the number of axes of 'this' mask");

        std::vector<size_t> offset(m_maskShape.NumAxes(), 0);
        for (size_t i = 0; i < sectionOffset.size(); ++i)
            offset[i] = sectionOffset[i];

        NDShape shape = sectionShape.AppendShape(NDShape(m_maskShape.NumAxes() - sectionShape.NumAxes(), NDShape::InferredDimension));

        auto maskMatrix = GetMatrix();
        size_t rowOffset = offset[0];
        size_t colOffset = offset[1];
        size_t sliceRowLength = (shape[0] != NDShape::InferredDimension) ? shape[0] : (maskMatrix->GetNumRows() - rowOffset);
        size_t sliceColLength = (shape[1] != NDShape::InferredDimension) ? shape[1] : (maskMatrix->GetNumCols() - colOffset);
        if ((rowOffset == 0) && (sliceRowLength == maskMatrix->GetNumRows()))
            maskMatrix->ColumnSlice(colOffset, sliceColLength).SetValue(0);
        else
        {
            // Since Matrix does not support strides in the row dimension, we will need to create separate slices for each column
            for (size_t i = colOffset; i < (colOffset + sliceColLength); ++i)
            {
                auto column = maskMatrix->ColumnSlice(i, 1);
                column.Reshape(1, maskMatrix->GetNumRows());
                column.ColumnSlice(rowOffset, sliceRowLength).SetValue(0);
            }
        }
    }
Ejemplo n.º 20
0
wxSVGRect wxSVGLineElement::GetBBox(wxSVG_COORDINATES coordinates)
{
  wxSVGPoint p1 = wxSVGPoint(GetX1().GetAnimVal(), GetY1().GetAnimVal());
  wxSVGPoint p2 = wxSVGPoint(GetX2().GetAnimVal(), GetY2().GetAnimVal());
  if (coordinates != wxSVG_COORDINATES_USER)
  {
    wxSVGMatrix matrix = GetMatrix(coordinates);
    p1 = p1.MatrixTransform(matrix);
    p2 = p2.MatrixTransform(matrix);
  }
  
  double x1 = p1.GetX();
  double y1 = p1.GetY();
  double x2 = p2.GetX();
  double y2 = p2.GetY();

  wxSVGRect bbox(x1, y1, x2 - x1, y2 - y1);
  
  if (x1 > x2)
  {
	bbox.SetX(x2);
	bbox.SetWidth(x1 - x2);
  }
  
  if (y1 > y2)
  {
	bbox.SetY(y2);
	bbox.SetHeight(y1 - y2);
  }
  
  return bbox;
}
Ejemplo n.º 21
0
    void NDMask::CopyFrom(const NDMask& source)
    {
        if (source.Shape() != Shape())
            InvalidArgument("NDMask::CopyFrom: The 'source' mask's shape must be same as the shape of this NDMask");

        GetMatrix()->AssignValuesOf(*source.GetMatrix());
    }
Ejemplo n.º 22
0
void Camera::GetMatrix(Matrix &m)
{
	if (dirty)
		GetMatrix();
	
	m.Set(matrix);
}
Ejemplo n.º 23
0
	void Execute(const Core3D::ShaderReg* pkIput, C3DVECTOR4& rkPosition, Core3D::ShaderReg* pkOutput)
	{
		// COMMENT : Transform position
		rkPosition	= pkIput[0] * GetMatrix(Core3D::SC_WVPMATRIX);
		// COMMENT : Pass texture coordinate to pixel shader
		pkOutput[0] = pkIput[1];
	}
Ejemplo n.º 24
0
void Sprite::Render()
{
    if (!ShouldDraw())
        return;

    UpdateTexture();

    SetBlendingMode(BlendingMode);

    // Assign our matrix.
    SetShaderParameters(ColorInvert, AffectedByLightning, Centered, false, BlackToTransparent);

    Mat4 Mat = GetMatrix();
    WindowFrame.SetUniform(U_MVP, &(Mat[0][0]));

    // Set the color.
    WindowFrame.SetUniform(U_COLOR, Red, Green, Blue, Alpha);

    SetTexturedQuadVBO(UvBuffer);
    DoQuadDraw();

    DrawLighten();

    FinalizeDraw();
}
Ejemplo n.º 25
0
bool Actor::IsCollide(const Actor& other, HitInfo& hitInfo) {

	if (body == nullptr) return false;
	if (other.body == nullptr) return false;

	return body->Transform(GetMatrix())->Intersect(
		*other.body->Transform(other.GetMatrix()), hitInfo);
}
Ejemplo n.º 26
0
 size_t NDMask::MaskedCount() const
 {
     auto maskMatrix = GetMatrix();
     std::unique_ptr<char[]> maskData(maskMatrix->CopyToArray());
     return std::count_if(maskData.get(), maskData.get() + maskMatrix->GetNumElements(), [](const char& val) {
         return val == 0;
     });
 }
Ejemplo n.º 27
0
already_AddRefed<SVGMatrix>
SVGMatrix::ScaleNonUniform(float scaleFactorX,
                           float scaleFactorY)
{
  nsRefPtr<SVGMatrix> matrix =
    new SVGMatrix(gfxMatrix(GetMatrix()).Scale(scaleFactorX, scaleFactorY));
  return matrix.forget();
}
void Model::Render(const Matrix4f& ltw, RenderDevice* ren)
{
    if (Visible)
    {
        Matrix4f m = ltw * GetMatrix();
        ren->Render(m, this);
    }
}
void Container::Render(const Matrix4f& ltw, RenderDevice* ren)
{
    Matrix4f m = ltw * GetMatrix();
    for(unsigned i = 0; i < Nodes.GetSize(); i++)
    {
        Nodes[i]->Render(m, ren);
    }
}
Ejemplo n.º 30
0
already_AddRefed<SVGMatrix>
SVGMatrix::FlipY()
{
  const gfxMatrix& mx = GetMatrix();
  nsRefPtr<SVGMatrix> matrix =
    new SVGMatrix(gfxMatrix(mx.xx, mx.yx, -mx.xy, -mx.yy, mx.x0, mx.y0));
  return matrix.forget();
}