public Transform ( double &px, double &py ) : void | ||
px | double | |
py | double | |
Résultat | void |
//---------------------------------------------------------------- public void Begin(double x, double y, int len) { // Calculate transformed coordinates at x1,y1 double xt = x; double yt = y; m_trans_dir.Transform(ref xt, ref yt); int x1 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y1 = AggBasics.iround(yt * SUBPIXEL_SCALE); double dx; double dy; double delta = 1 / (double)SUBPIXEL_SCALE; // Calculate scale by X at x1,y1 dx = xt + delta; dy = yt; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sx1 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate scale by Y at x1,y1 dx = xt; dy = yt + delta; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sy1 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate transformed coordinates at x2,y2 x += len; xt = x; yt = y; m_trans_dir.Transform(ref xt, ref yt); int x2 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.iround(yt * SUBPIXEL_SCALE); // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sx2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.Transform(ref dx, ref dy); dx -= x; dy -= y; int sy2 = (int)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (int)len); }
void scaling(out double x, out double y) { double x1 = 0.0; double y1 = 0.0; double x2 = 1.0; double y2 = 1.0; Perspective t = new Perspective(this); t *= Affine.NewRotation(-rotation()); t.Transform(ref x1, ref y1); t.Transform(ref x2, ref y2); x = x2 - x1; y = y2 - y1; }
// Inverse transformation of x and y. It works slow because // it explicitly inverts the matrix on every call. For massive // operations it's better to invert() the matrix and then use // direct transformations. void inverse_transform(ref double x, ref double y) { Perspective t = new Perspective(this); if (t.invert()) { t.Transform(ref x, ref y); } }
void scaling(out double x, out double y) { double x1 = 0.0; double y1 = 0.0; double x2 = 1.0; double y2 = 1.0; Perspective t = new Perspective(this); t *= Affine.NewRotation(-rotation()); t.Transform(ref x1, ref y1); t.Transform(ref x2, ref y2); x = x2 - x1; y = y2 - y1; }
// Inverse transformation of x and y. It works slow because // it explicitly inverts the matrix on every call. For massive // operations it's better to invert() the matrix and then use // direct transformations. void inverse_transform(ref double x, ref double y) { Perspective t = new Perspective(this); if (t.invert()) t.Transform(ref x, ref y); }