8 Replies Latest reply: Feb 15, 2010 11:37 PM by 843853 RSS

    2D plane reflection

    843853
      Now I know my physics, when a body collides with a plane, angle of reflection = angle of incidence. The angle is counted from the normal of the 2d plane or line. But what I want to know is, how would I find the angle of the normal from a line with two coordinates? Wouldn't there be two normals, one side and the other?
        • 1. Re: 2D plane reflection
          843853
          If you are talking random collisions in space:

          arcTan(dY/dX ) = Theta
          cos(Theta) * Scale (movement distance) = X vector
          sin(Theta) * Scale (movement distance) = Y vector

          Do this for each object and add up all the X vectors, than add up all the Y vectors separately. Now from the point of contact you have a dY/dX so you can calculate the new angle Theta.
          • 2. Re: 2D plane reflection
            843853
            You have a given that there is a right angle involved, do you have a dY/dX value from your trajectory so atan(dY/dX)=angle, transpose the origin to your impact point and change your dY/dX appropriately--Or if you impact in the X direction, just negate your X inc and you have it, the same goes for the Y.
            • 3. Re: 2D plane reflection
              843853
              I have a body, in this case a ball, colliding with a line. I need the angle of the normal on this line.
              • 4. Re: 2D plane reflection
                843853
                dY/dX of your line gives you the slope in your screen coordinate system:

                arcTan(dY/dX)+90 will give you a normal to that line. This will work for all random angles in your coordinate system.

                please take note, that scale*cos(angle) and scale*sin(angle) will still give vectors back into your coordinate system if you work it this way.
                • 5. Re: 2D plane reflection
                  843853
                  what exactly is dY and dX? sorry.
                  • 6. Re: 2D plane reflection
                    843853
                    dX is read as dee-ex and dY is read as dee-why. In calculus they mean the change in X and the Change in Y, when you see dX/dY it is a derivative and gives a tangent to a curve. In your case it is used as the tangent, and simply calculated by (X1-X0)/(Y1-Y0). To get the curve itself you use the inverse of the Tangent function or ArcTan.
                    • 7. Re: 2D plane reflection
                      jwenting
                      tomster1996 wrote:
                      what exactly is dY and dX? sorry.
                      you claim to know physics and don't know the symbology related to the mathematical representation of even simple mechanics?
                      • 8. Re: 2D plane reflection
                        843853
                        jwenting wrote:
                        tomster1996 wrote:
                        what exactly is dY and dX? sorry.
                        you claim to know physics and don't know the symbology related to the mathematical representation of even simple mechanics?
                        If I already knew about this, i wouldn't need to be here. I've got this sorted anyway.