Friday, June 04, 2010

Where will it end up ?

I received a great question from one of my Surface students today.
They wanted to know if they can calculate where a ScatterViewItem is going to end up when it is flicked. Or the other way around, could you set an end point and set up the inertia processor to move an item to that location.

Lets say i have a ScatterViewItem on position point(30,130) and i want it to go to point(550,300).
How can I set the following:

// settings
inertiaProcessor.InitialOrigin = new Point(30,130);
inertiaProcessor.DesiredDeceleration = ?;
inertiaProcessor.InitialVelocity = ?;

// Restart Inertia
inertiaProcessor.Begin();

// Now please end up at: new Point(550,300);


Sadly there is no way to know this with precision. In theory you could use the physics formula to calculate this. The precision is not that accurate though so you would probably be a little off.
Remember one of the objectives of the ScatterView is to scatter things in an apparent random manner on the screen.
If you wanted to build an application where the exact location of movable items is important then a ScatterView control might not be the best option.

2 comments:

JoshB said...

What about Affine2DInertiaProcessor.DesiredDisplacement, DesiredExpansion, and DesiredRotation? You can set those instead of the deceleration and the inertia processor will calculate the necessary deceleration for you. You still need to specify the initial position, scale, and/or velocity.

http://msdn.microsoft.com/en-us/library/microsoft.surface.presentation.manipulations.affine2dinertiaprocessor_members%28v=Surface.10%29.aspx

Dr. Neil said...

Hi josh,

this is a great point and would work for sending an item to a certain location. It doesn't solve the first issue of determining where a _flicked_ scatter view item will end up.
Thanks.