A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [CS3] Angles And Collisions

  1. #1
    Senior Member
    Join Date
    Apr 2007
    Posts
    269

    Exclamation [CS3] Angles And Collisions

    Hi at the moment I'm working on my physics engine for my new game and I have a problem. To help you understand I drew a diagram.



    At the moment I have a hitTest that between a ball and 45 degrees surface.

    The ball is travelling at "n" degrees which as shown is in between -180, 0, 180 as shown in the diagram of where the corresponding sides are. What I want to know is what angle should the ball be travelling in after it collides with the surface.

    Using 'n' does anyone know of such an equations which would do such a thing?

    Please help!
    Last edited by unrealhacker12; 07-14-2008 at 07:46 PM.

  2. #2
    Senior Member
    Join Date
    Apr 2007
    Posts
    269
    If I made it so that its 360 degrees instead of what it is know would that help?

  3. #3
    Senior Member
    Join Date
    Apr 2007
    Posts
    269
    Someone atleast say they have not a clue?

  4. #4
    Senior Member
    Join Date
    Apr 2007
    Posts
    269
    Alot of help this community is then.

  5. #5
    Member
    Join Date
    May 2007
    Posts
    55
    Seems like a straightforward physics question.

    Basically the angle of incidence is equal to the angle of relection. (1st law of reflection)
    The angle subtended between the incoming line and the normal to the surface at the point of impact is the angle of incidence. The angle of relection is the same angle only on the other side of the normal.
    A normal is a line at 90º (perpendicular) to the surface.

  6. #6
    Member
    Join Date
    May 2007
    Posts
    55
    if your mc has it's x velocity before collision controlled by:

    xPos:Number = 10

    var xSpeed = function(){
    mc._x+=xPos;
    }

    then after collision the velocity will be given by:
    mc._x-=xPos;

    The same applies to the _y vector

  7. #7
    Member
    Join Date
    May 2007
    Posts
    55
    In terms of angles.

    From your diagram the ball will strike the surface at 90º (to the surface) when n=135 and it will reflect at an angle of -45º (from your figures on the sphere)
    Therefore angle of reflection = angle of incidence, or from your values

    So if n< 135 then the incident angle = (135-n) and the reflected angle is 45 - (135-n) = -(90+n)

    If n>135 the incident angle = (n-135) and the reflected angle = 45 + (n-135) = (n-90)

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