DynaPDF Manual - Page 588

Function Reference
Page 588 of 818
All transformations above can occur in any combination in one transformation matrix.
Helper Functions
The following functions are helpful and some of them are required when working with
transformation matrices. To achieve maximum execution speed the source codes of the most
important functions are provided:
// Distance between two points
double CalcDistance(double x1, double y1, double x2, double y2)
{
double dx = x2-x1;
double dy = y2-y1;
return sqrt(dx*dx + dy*dy);
}
double GetRotationAngle(TCTM &M)
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 0.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
return atan2(y2-y1, x2-x1);
}
// Overall scaling factor
double GetScaleFactor(TCTM &M)
{
#define sin45 0.70710678118654752440084436210485
double x = sin45 * M.a + sin45 * M.c;
double y = sin45 * M.b + sin45 * M.d;
return sqrt(x*x + y*y);
}
// Scaling factor of the x-axis
double GetScaleX(TCTM &M)
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 0.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
if (x1 > x2)
return -CalcDistance(x1, y1, x2, y2);
else
return CalcDistance(x1, y1, x2, y2);
}
// Scaling factor of the y-axis
double GetScaleY(TCTM &M)

Previous topic: Working with Transformation Matrices

Next topic: Text Coordinates and Metrics, Font Size