When the moon reflects from a lake, as shown in Figure 5, a combination of these effects takes place. A mirror, on the other hand, has a smooth surface (compared with the wavelength of light) and reflects light at specific angles, as illustrated in Figure 4. Many objects, such as people, clothing, leaves, and walls, have rough surfaces and can be seen from all sides. Diffused light is what allows us to see a sheet of paper from any angle, as illustrated in Figure 3. Since the light strikes different parts of the surface at different angles, it is reflected in many different directions, or diffused. We expect to see reflections from smooth surfaces, but Figure 2 illustrates how a rough surface reflects light. The law of reflection is illustrated in Figure 1, which also shows how the angles are measured relative to the perpendicular to the surface at the point where the light ray strikes. The angles are measured relative to the perpendicular to the surface at the point where the ray strikes the surface.
The law of reflection states that the angle of reflection equals the angle of incidence- θr = θi. This is certainly not the best way to go and I'm sure you can just calculate it in some way but I think it's a possible solution to your problem.Figure 1. You could just create a vector for these calculations or keep the same general idea but working with angles. Note: I noticed that you're using an angle to represent the direction instead of a vector. After, you rotate back to your real situation. You rotate by 70 degrees, check where the collision was from, and reverse the appropriate components. On the second case, it's the same thing, except that the ball's velocity is not perpendicular to the block. After that, you just have to rotate back to the real situation (which is not on the drawing). This will also make the ball act correctly when it hits corners (it will reverse both components). If it was vertical (like in this case), the y component ( = ). If the collision was horizontal, reverse the x component of the velocity. Then, you check where the collision was from. Example 1: A light ray strikes a reflective plane surface at an angle of 56 with the surface. What you need to do is rotate everything by 30 degrees (the inclination of the block) (you can use matrices for that). One of the way to fix the collision problem is to bring everything back on the horizontal axis. On the first case, the blue block has an inclination of 30 degrees. The green arrows represent the ball's velocity (as a vector), the blue blocks represent your large black blocks and the red arrow is the resultant vector. Medium where light coming form must have higher index of refraction compared to second medium ( n > n t) For any angle of incidence less than the. For total internal reflection, Incident angle > Critical angle. Here's a quick drawing on my white board that shows a possible solution for that: The critical angle can be calculated from Snells law by setting the refraction angle equal to 90°. I'm not sure if I understood your problem correctly, but I assumed that what you want to do is find the resultant direction of you ball after a collision. I'll open another question for that and link it here. Ok, the problem with angles was solved with Vectors, but I still have the problem with sides and back collision.
#FINDING ANGLE OF REFLECTION CODE#
Ps: If needed, I can supply code and a playable swf.
More than that, the ball should hit the sides too, so, how can I measure the direction of the hit and the new direction of movement of the ball? My problem comes now, with the pads (the 3 dark and large blocks around the small colored blocks).Īs they turn around, the surface angle changes. The ball is moved by: // Event.ENTER_FRAME Where the blue line is the ball direction, and the black line (base line) is the block surface.ĭirection is a angle expressed in radian (that can be convert to degrees, of course). I've managed to get the collision per pixel and my ball " reflects" on contact with the blocks with the following math: Ball.Direction = 2 * (Block.Direction - Ball.Direction) + 180
I have a cannon at the center, blocks around the cannon and pads around the blocks.