dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Need some help with acceleration and velocity

  1. #1
    Likes Pankakes
    Join Date
    Mar 2008
    Location
    Germany
    Posts
    59

    Need some help with acceleration and velocity

    Hi guys,

    I need some help calculating the velocity with acceleration. To start off, I'll give a short description of what I'm trying to build.



    It's in german sorry, but anyone who has had physics in school will probably remember talking about this. Then the electrons move into the electric field of the first parallel plate capacitor they get diverted (that the correct word? ...sorry about my english). I think you know what I mean :P. They get attracted to the plate with the positive charge. Before they enter they only have the constant velocity in the direction of x...when they enter the field, they get get an additional velocity in the direction of y. I'm not going to go into how to calculate the velocity x (assume that it's constant)...but the velocity in the direction of y is calculated:

    v = a * t ....whereas a = (Q * U) / (m * d) ...the latter is not so important...just an info.

    I am trying to simulate the movement of this electron in flash...it's working so far but I have little experience with coding in AS2. Any AS actually. But I've got it working so that the particle gets diverted with the constant speed v in the direction of y....so there's no acceleration. How would I go about doing this? I can calculate the acceleration...but how do I get t? v = s / t ===> t = s/v...but how can I tell flash where to to start measuring t?

    Hope my explanation was okay :P

    Cheers!

  2. #2
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    t is your variable. assuming acceleration is constant, then position can be solved for at t:
    x1 = x0 + v * t + 0.5 * a * t * t
    if acceleration isn't constant, then position is a function of more than time and you'll need to address the problem differently- i can help with that, but i want to rule out constant acceleration first.

  3. #3
    Likes Pankakes
    Join Date
    Mar 2008
    Location
    Germany
    Posts
    59
    yes the acceleration is constant. (Q * U) / (m * d) are all constant in this case...the user can edit U and d but only before running the simulation. Well since t is my variable, the speed in the direction of y must also vary seeing as it is calculated v = a * t ...but how would I go about getting t and telling flash where to start calculating it. would it be t(x) = v0 / (x0 + v * t + 0.5 * a * t^2)? and x0 just being defined at the point of entry into the field?

  4. #4
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    seems like you're on the right path- x0 is the position when t = 0. velocity should only be solved for initially, after that you're only solving for position with respect to time.

  5. #5
    Likes Pankakes
    Join Date
    Mar 2008
    Location
    Germany
    Posts
    59
    okay that seems solved. My inexperience with code still wont allow me to do this though. How do I get the values for x0 via code?

  6. #6
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    x0 is the x and y position of your electron when you start the simulation (when t = 0)

  7. #7
    Likes Pankakes
    Join Date
    Mar 2008
    Location
    Germany
    Posts
    59
    okay thanks for the help!

  8. #8
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    Let me blow my horn a little? Here is how to do it with tweener. You will have to type your equation in, and that's it.
    who is this? a word of friendly advice: FFS stop using AS2

  9. #9
    Likes Pankakes
    Join Date
    Mar 2008
    Location
    Germany
    Posts
    59
    thanks...seeing as I don't understand most of it Ill have to look into it...I do program in C++ so I was thinking of just programming a function that loops and always calculates the position and returns the value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center