Results 1 to 2 of 2

Thread: Curved Motion Modelled as its Components

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Curved Motion Modelled as its Components

    I use the following code each frame to control the movement of a ball. It works fine apart from I'm not sure how to apply a spin to the ball.

    The Z component can be ignored becuase this will be more or less a constant.

    Basically the ball is moving in side a box, along the Z axis toward the other side, when it reachs it it bounces and comes back, it continues doing this getting faster each time. On its way it can bounce off the other sides as it goes.

    On the ends when it bounces back it is boncing off a moving surface, when this happens (I have the X,Y velocity of the moving surface) it will be given a spin based on how fast the surface was moving. I have tried giving the Acceleration the speed the surface was moving then giving the 2Acc (Rate of chnage of Acceleration) the negative speed but it doesn't seem to work . Does anyone have any idea?

    Thanx.

    VB Code:
    1. 'Adjust the Acceleration based on 2Acc...
    2.     Ball.XAcc = Ball.XAcc + Ball.X2Acc
    3.     Ball.YAcc = Ball.YAcc + Ball.Y2Acc
    4.     Ball.ZAcc = Ball.ZAcc + Ball.Z2Acc
    5.    
    6.     'Adjust Velocity due to acceleration...
    7.     Ball.XVel = Ball.XVel + Ball.XAcc
    8.     Ball.YVel = Ball.YVel + Ball.YAcc
    9.     Ball.ZVel = Ball.ZVel + Ball.ZAcc
    10.    
    11.     'Degrade the change in acceleration....
    12.     Ball.X2Acc = Ball.X2Acc * 0.999
    13.     Ball.Y2Acc = Ball.Y2Acc * 0.999
    14.     Ball.Z2Acc = Ball.Z2Acc * 0.999
    15.    
    16.     If Abs(Ball.X2Acc) < 0.000001 Then Ball.X2Acc = 0
    17.     If Abs(Ball.Y2Acc) < 0.000001 Then Ball.Y2Acc = 0
    18.     If Abs(Ball.Z2Acc) < 0.000001 Then Ball.Z2Acc = 0
    19.    
    20.     'Apply CofFriction...
    21.     Ball.XVel = Ball.XVel * 0.07
    22.     Ball.YVel = Ball.YVel * 0.07
    23.     Ball.ZVel = Ball.ZVel * 0.07
    24.    
    25.     'Adjust the Position due to velocity...
    26.     Ball.XPos = Ball.XPos + Ball.XVel
    27.     Ball.YPos = Ball.YPos + Ball.YVel
    28.     Ball.ZPos = Ball.ZPos + Ball.ZVel
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Sorry I forgot to attach this, it shows what I'm after. To use it just open it in IE.
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

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