private IUnitTransformation ResetTransform() { var mov = Matrix.Translation(-_document.Selection.GetSelectionBoundingBox().Center); OpenTK.Quaternion rev = new OpenTK.Quaternion((float)PrevRotation.X, (float)PrevRotation.Y, (float)PrevRotation.Z, (float)PrevRotation.W); rev.Invert(); var q = new DataStructures.Geometric.Quaternion(0, 0, 0, -1); var rot = Matrix.Rotation(q); var fin = Matrix.Translation(SolidsOrigin); PrevRotation = new DataStructures.Geometric.Quaternion((decimal)rev.X, (decimal)rev.Y, (decimal)rev.Z, (decimal)rev.W); var prev = Matrix.Rotation(PrevRotation); PrevRotation = q; return new UnitMatrixMult(fin * (rot * prev) * mov); }
private IUnitTransformation KeyFrameTransform() { var mov = Matrix.Translation(-_document.Selection.GetSelectionBoundingBox().Center); // Move to zero OpenTK.Quaternion rev = new OpenTK.Quaternion((float)PrevRotation.X, (float)PrevRotation.Y, (float)PrevRotation.Z, (float)PrevRotation.W); rev.Invert(); PrevRotation = new Quaternion((decimal)rev.X, (decimal)rev.Y, (decimal)rev.Z, (decimal)rev.W); var prev = Matrix.Rotation(PrevRotation); Quaternion q = GetKeyframeRot(); var rot = Matrix.Rotation(q); // Do rotation var fin = Matrix.Translation(SolidsOrigin + GetKeyframeMov()); // Move to final origin PrevRotation = q; return new UnitMatrixMult(fin * (rot * prev) * mov); }