home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
- ADOBE SYSTEMS INCORPORATED
- Copyright 2002 Adobe Systems Incorporated
- All Rights Reserved
-
- NOTICE: Adobe permits you to use, modify, and distribute this
- file in accordance with the terms of the Adobe license agreement
- accompanying it. If you have received this file from a source
- other than Adobe, then your use, modification, or distribution
- of it requires the prior written permission of Adobe.
- ***************************************************************/
- /***************************************************************
- Author: Mary Obelnicki
- ***************************************************************/
-
- /***************************************************************
-
- This include includes two functions that facilitate the calculate
- of objects moving in space. These functions depend on the include,
- Vector.js. Please see Vector.js for details on Vector objects.
-
- newPosition(position, velocity, acceleration, dt)
- takes the initial conditions for position, velocity, and
- acceleration and returns the position after <dt>. The function
- assumes constant forces (i.e. no changes in acceleration)
-
- Arguments:
- <position> vector of the initial position
- <velocity> vector of the initial velocity
- <acceleration> vector of the acceleration
- <dt> amount of time to pass, forward in time
-
- newVelocity(velocity, acceleration, dt)
- takes the initial condition for velocity and acceleration
- and returns the velocity after <dt>.
-
- Arguments:
- <velocity> vector of the initial velocity
- <acceleration> vector of the acceleration
- <dt> amount of time to pass, forward in time
-
- ***************************************************************/
-
- /***************************************************************
- DO NOT EDIT BELOW THIS LINE
- ***************************************************************/
-
- #include "Vector.js"
-
- function newPosition(position, velocity, acceleration, dt)
- {
- var ddt = Vector.add(Vector.scalerMult(velocity, dt),
- Vector.scalerMult(acceleration, dt*dt/2));
- return Vector.add(position, ddt);
- }
-
- function newVelocity(velocity, acceleration, dt)
- {
- return Vector.add(velocity,
- Vector.scalerMult(acceleration, dt));
- }
-
- function previousPosition(position, velocity, acceleration, dt)
- {
- return newPosition(position,
- Vector.scalerMult(velocity, -1),
- acceleration,
- dt);
- }
-
- function previousVelocity(velocity, acceleration, dt)
- {
- return newVelocity(velocity,
- Vector.scalerMult(acceleration, -1),
- dt);
- }
-
-
-