T.R | Title | User | Personal Name | Date | Lines |
---|
1833.1 | | STAR::ABBASI | and the computer said mate in 23! | Tue Jan 11 1994 14:15 | 4 |
| is this different from calculating the mass of an object ?
\nasser
|
1833.2 | | WRKSYS::ARUMUGHAM | | Tue Jan 11 1994 17:26 | 3 |
| Well, this person wants a marble to move when you move the mouse in a
program, but the marble needs to realistically accelerate and
decelerate with the mouse movement...
|
1833.3 | | 3D::ROTH | Geometry is the real life! | Tue Jan 11 1994 18:13 | 33 |
| > Well, this person wants a marble to move when you move the mouse in a
> program, but the marble needs to realistically accelerate and
> decelerate with the mouse movement...
If you specify the force exerted on the marble, its's a straightforward
initial value problem and you can use any of a number of ordinary
differential equation solvers.
You'll need specify the state of the marble - it's x and y position
and x and y components of velocity - as initial conditions. Then
Newton's second law, force = mass * acceleration defines the
path of the marble.
Actually, even the simplest first order solver will probably suffice.
Try updating your position and velocity with
loop:
Px = Px + Vx * dt
Py = Py + Vy * dt
Vx = Vx + (Fx / Mass) * dt
Vy = Vy + (Fy / Mass) * dt
goto loop
More accurate solvers are expansions on this trivial idea.
You may want to add friction, which is another component of
force proportional to velocity, to the model above.
- Jim
|
1833.4 | Attaching it to the mouse | WIBBIN::NOYCE | DEC 21064-200DX5 : 130 SPECint @ $36K | Wed Jan 12 1994 11:47 | 15 |
| You might want to model the "current mouse position" as being attached to
the marble via a spring (or rubber band). The force exerted by a spring
stretched to length L is proportional to L.
So, if (Px,Py) represents the marble's position, and (Mx,My) represents the
mouse position, then L=SQRT( (Mx-Px)**2 + (My-Py)**2 ) is the spring's length,
and
Fx = K*L*(Mx-Px)/L
Fy = K*L*(My-Py)/L
are the x- and y- components of the spring's force, for some "spring constant"
K. (Note that the L's cancel out, so no need to compute them.) Experiment
with different values for K to get behavior you like.
PS- you'll want to add some friction, or you'll get oscillation that's very
hard to control!
|
1833.5 | if nobody has a canned algorithm handy... | ICARUS::NEILSEN | Wally Neilsen-Steinhardt | Wed Jan 12 1994 12:08 | 29 |
| .2> Well, this person wants a marble to move when you move the mouse in a
> program, but the marble needs to realistically accelerate and
> decelerate with the mouse movement...
I will temporarily stifle my impulse to ask why. I suspect this is one of those
user requirements which has a different actual requirement behind it.
I can see several ways to make the marble move "realistically."
The simplest way would be to let the mouse move an acceleration cursor on an
acceleration grid, and then plug the acceleration into equations like those
in reply 3. Problem is that this is contrary to the usual mouse-cursor
metaphor. As I remember, early computer games used this method, and it was
quite frustrating. To stop the "marble," you had to apply just the right
deceleration, and then hold the acceleration cursor at the zero point of
its grid.
Another way would be to allow the mouse to control a cursor in the space of the
marble. This cursor, which would be controlled by the mouse in the usual way,
would be tied to the marble by an ideal spring. In other words, the force
and acceleration on the marble would always be proportional to the distance
between the marble and the cursor. Again the equations in reply 3 could be
used to model the marble's position. If you did just this, you would find that
the marble would never settle down once it started moving. It would just
oscillate around the current position of the cursor. As reply 3 suggests,
you might want to add some kind of frictional force, perhaps decreasing velocity
as the marble moves away from the cursor.
By now, this is really a physics problem.
|
1833.6 | (-: | AUSSIE::GARSON | Hotel Garson: No Vacancies | Mon Jan 24 1994 01:14 | 4 |
| re .0
Calculating *moment of* inertia is more interesting mathematically. Is
it required that the rolling of the marble be accounted for?
|
1833.7 | | FORTY2::PALKA | | Mon Jan 24 1994 12:13 | 8 |
| re .6
Especially if you want to allow for friction between the marble and the
surface it moves on (I.e. can it roll with slipping ?), and rolling
resistance (so that it eventually stops when you stop moving the
mouse).
Andrew
|