public OoxTransform(OoxTransform outer, OoxTransform inner) { // Get the Bounding box of the most inner transformation _x = inner.X; _y = inner.Y; _cx = inner.CX; _cy = inner.CY; // Now combine all transformations (5.7.4, "Render a simple shape inside a group hierarchy", steps 1, 2, 3) _rot = Normalize(outer._rot + inner._rot); _flipH = outer._flipH * inner._flipH; _flipV = outer._flipV * inner._flipV; _scaleX = outer._scaleX * inner._scaleX; _scaleY = outer._scaleY * inner._scaleY; TransformationMatrix m = outer._transform * inner._transform; // Note : the center should be invariant by inner._transform... // Calculate the coordinates of the new Center (5.7.4, "Render a simple shape inside a group hierarchy", step 4) PointCoordinates originalCenter = new PointCoordinates(_x + _cx / 2.0, _y + _cy / 2.0); PointCoordinates newCenter = m.Transform(originalCenter); // Now calculate the target "Bounding box" double newCx = _cx * _scaleX; double newCy = _cy * _scaleY; double newX = newCenter.X - newCx / 2.0; double newY = newCenter.Y - newCy / 2.0; // And finally compute the transformation matrix... CreateMatrix(_x, _y, _cx, _cy, newX, newY, newCx, newCy, _rot, _flipH, _flipV); }
public void Transform(double x, double y, out double newX, out double newY) { PointCoordinates sourcePt = new PointCoordinates(x, y); PointCoordinates newPt = _transform.Transform(sourcePt); newX = newPt.X; newY = newPt.Y; }
public PointCoordinates Transform(PointCoordinates pt) { return(new PointCoordinates(_v11 * pt.X + _v12 * pt.Y + _v13 * pt.Z, _v21 * pt.X + _v22 * pt.Y + _v23 * pt.Z, _v31 * pt.X + _v32 * pt.Y + _v33 * pt.Z)); }