コード例 #1
0
ファイル: doccoord.cpp プロジェクト: Amadiro/xara-cairo
XMatrix ComposeDocToWorkXMat(const DocCoord ChapterPos,	// Top left coord of chapter
                          const XLONG ChapterDepth,		// Accumulated height of previous chaps
                          const FIXED16 ViewScale		// User viewing scale
                        )
{

    XMatrix ScaleMat(ViewScale,ViewScale);

// Conversion of chapter position from DocCoords to WorkCoords
//    WorkCoord WrkChapPos(MakeXLong(ChapterPos.x), MakeXLong(ChapterPos.y));
    WorkCoord WrkChapPos(MakeXLong(ChapterPos.x), MakeXLong(ChapterPos.y)+ChapterDepth);

// DocToOS matrix is initialised as the Translate matrix: saving space and performance
// by the exclusion of an extra multiplication.
	XMatrix DocToWork(-(WrkChapPos));
    
// The following matrix compositions MUST be performed in this order. If you are tempted
// to optimise this code MAKE SURE THAT THEY ARE STILL IN THIS ORDER WHEN YOU'VE FINISHED!
//

// Apply scale factors to convert from millipoint distances to pixel distances...
    DocToWork *= ScaleMat;

    return DocToWork;
}
コード例 #2
0
ファイル: conmat.c プロジェクト: BonsaiDen/GraphicsGems
/* Compute the inverse of the transformation
   which turns an ellipse into a circle */
void InvElp2Cir(Ellipse *Elp,TMat *InvMat)
   {
   /* Start with identity matrix */
   *InvMat = IdentMat;
   /* Scale back into an ellipse. */
   ScaleMat(InvMat,Elp->MaxRad,Elp->MinRad);
   /* Rotate */
   RotateMat(InvMat,Elp->Phi);
   /* Translate from origin */
   TranslateMat(InvMat,Elp->Center.X,Elp->Center.Y);
   }
コード例 #3
0
ファイル: conmat.c プロジェクト: BonsaiDen/GraphicsGems
/* Compute the transformation which turns an ellipse into a circle */
void Elp2Cir(Ellipse *Elp,TMat *CirMat)
   {
   /* Start with identity matrix */
   *CirMat = IdentMat;
   /* Translate to origin */
   TranslateMat(CirMat,-Elp->Center.X,-Elp->Center.Y);
   /* Rotate into standard position */
   RotateMat(CirMat,-Elp->Phi);
   /* Scale into a circle. */
   ScaleMat(CirMat,1.0/Elp->MaxRad,1.0/Elp->MinRad);
   }
コード例 #4
0
ファイル: doccoord.cpp プロジェクト: Amadiro/xara-cairo
Matrix ComposeDocToOilMat( const DocCoord& ChapterPos,	// Top left coord of chapter
                          const XLONG& ChapterDepth,		// Accumulated height of previous chaps
                          const FIXED16& ViewScale,		// User viewing scale
                          const WorkCoord& ScrollOffset	// Scroll offsets
                        )
{
// Scale ChapterDepth into device units so that it can be combined with the scroll offset
// BEFORE we build the scroll translation matrix. In this way we avoid storing 64-bit
// translation values in our final matrix...
//
// If we COULD store 64-bit E and F values temporarilly during this composition then
// we would not need to perform this trick at all. This would have the knock-on advantage
// that the OSMapping matrix supplied by the OIL layer could contain the scroll offsets!
//
// NOTE: This adjustment can be removed when testing the system!

    Matrix DocToOil;

//**********************************************************************
// Is it just me or is there gunna be a problem with this ?
// If ChapterDepth is big (atfer all it is an XLONG) and ViewScale
// is big too (Say we are zoomed to 1000%) won't this go VERY wrong ?
//
// - Will.

    Matrix Scroll(	-ScrollOffset.x,
    				-(ScrollOffset.y + (ChapterDepth * (ViewScale)))
    			 );

//**********************************************************************

    Matrix ScaleMat(ViewScale,ViewScale);
	Matrix Translate(-((Coord)ChapterPos));

// The following matrix compositions MUST be performed in this order. If you are tempted
// to optimise this code MAKE SURE THAT THEY ARE STILL IN THIS ORDER WHEN YOU'VE FINISHED!
//
// Apply translation to get coordinates into logical column...
    DocToOil *= Translate;

// Apply scale factors to convert from millipoint distances to pixel distances...
    DocToOil *= ScaleMat;

// Apply scroll-offset translation to move origin to viewing position...
    DocToOil *= Scroll;

    return DocToOil;
}
コード例 #5
0
ファイル: MathUtil.cpp プロジェクト: hedgefair/DeepTerrainRL
tMatrix cMathUtil::ScaleMat(double scale)
{
	return ScaleMat(tVector::Ones() * scale);
}