void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src) { D2D1_MATRIX_3X2_F c, d; m2d(dest, &c); m2d(src, &d); c = c * d; d2m(&c, dest); }
int uiDrawMatrixInvertible(uiDrawMatrix *m) { D2D1_MATRIX_3X2_F d; m2d(m, &d); return D2D1IsMatrixInvertible(&d) != FALSE; }
void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y) { D2D1_MATRIX_3X2_F dm; m2d(m, &dm); dm = dm * D2D1::Matrix3x2F::Translation(x, y); d2m(&dm, m); }
int uiDrawMatrixInvert(uiDrawMatrix *m) { D2D1_MATRIX_3X2_F d; m2d(m, &d); if (D2D1InvertMatrix(&d) == FALSE) return 0; d2m(&d, m); return 1; }
void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount) { D2D1_MATRIX_3X2_F dm; D2D1_POINT_2F center; m2d(m, &dm); center.x = x; center.y = y; dm = dm * D2D1::Matrix3x2F::Skew(r2d(xamount), r2d(yamount), center); d2m(&dm, m); }
void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount) { D2D1_MATRIX_3X2_F dm; D2D1_POINT_2F center; m2d(m, &dm); center.x = x; center.y = y; dm = dm * D2D1::Matrix3x2F::Rotation(r2d(amount), center); d2m(&dm, m); }
void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y) { D2D1_MATRIX_3X2_F dm; D2D1_POINT_2F center; m2d(m, &dm); center.x = xCenter; center.y = yCenter; dm = dm * D2D1::Matrix3x2F::Scale(x, y, center); d2m(&dm, m); }
void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y) { D2D1::Matrix3x2F dm; D2D1_POINT_2F pt; m2d(m, &dm); pt.x = *x; pt.y = *y; pt = dm.TransformPoint(pt); *x = pt.x; *y = pt.y; }
shared_ptr <Mapper2d> Mapper2d:: Create (GridFrame const & gframe, double robot_radius, double buffer_zone, double decay_power) { shared_ptr <travmap_cost_decay> cost_decay (new exponential_travmap_cost_decay (decay_power)); shared_ptr <travmap_grow_strategy> grow_strategy (new always_grow()); shared_ptr <TraversabilityMap> travmap (new TraversabilityMap (gframe, 0, 0, 0, 0)); static double const padding_factor (2.0); shared_ptr <Mapper2d> m2d (new Mapper2d (robot_radius, buffer_zone, padding_factor, cost_decay, travmap, grow_strategy)); return m2d; }
void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m) { D2D1_MATRIX_3X2_F dm; uiDrawMatrix already; uiDrawMatrix temp; ID2D1RenderTarget_GetTransform(c->rt, &dm); d2m(&dm, &already); temp = *m; // don't modify m // you would think we have to do already * m, right? // WRONG! we have to do m * already // why? a few reasons // a) this lovely comment in cairo's source - http://cgit.freedesktop.org/cairo/tree/src/cairo-matrix.c?id=0537479bd1d4c5a3bc0f6f41dec4deb98481f34a#n330 // Direct2D uses column vectors and I don't know if this is even documented // b) that's what Core Graphics does // TODO see if Microsoft says to do this uiDrawMatrixMultiply(&temp, &already); m2d(&temp, &dm); ID2D1RenderTarget_SetTransform(c->rt, &dm); }