Right, i think i've implimented option 2, however i'm still getting the same issue so obviously i've done something slightly wrong.
It looks like up until about half way through the animation the panning looks ok, but then it very rapidly seems to speed up.
Here is my c# version of the integration routine:With an small wrapper function that calls it passing in the M(x) function.Code:private double Integrate(Func<double, double> f, double Start, double End) { double Size = (End - Start) / 10000.0; double Result = 0.0; for (double i = Start; i < End; i += Size) { Result += f(i) * Size; } return Result; }
iR is the initial rectangle and fR is the final rectangle.Finally, here's my code that calculates the x,y coordinates as well as the width and height (variables tX, tY, tW, tH respectively):Code:private double I(RectangleD iR, RectangleD fR, double t) { double W = Math.Pow(iR.Width / fR.Width, 2); double H = Math.Pow(iR.Height / fR.Height, 2); return Integrate( (T) => 1 / Math.Sqrt(Math.Pow(W, T) + Math.Pow(H, T)), 0, t); }I'm hoping that i've just misunderstood the mathematical notation in your post and so got something wrong with the translation into code. I can follow the workings in your post (although the ideas etc. are certainly beyond what i could come up with!) so i'm a bit unsure where i've gone wrong.Code:double double tX, tY, tW, tH; //Calculate Width double i = iR.Width; double f = fR.Width; tW = i * Math.Pow(f / i, t); //Calculate Height i = iR.Height; f = fR.Height; tH = i * Math.Pow(f / i, t); //Calculate X double V = (fR.X - iR.X) / I(iR, fR, 1); tX = iR.X + V * I(iR, fR, t); //Calculate Y V = (fR.Y - iR.Y) / I(iR, fR, 1); tY = iR.Y + V * I(iR, fR, t);





Reply With Quote