Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Lights and Mirrors

malaxmalax Member Posts: 2
Here is a brain teaser that I couldn't figure out. Can you help me:

The Scenario
In an enclosed area (your form), there should be located a number of points (no more than 4) through which a ray of light must pass. The light ray emerges in a specific direction from a fixed point.
The light is then deflected by reflection using a suitable number of plane mirrors.
NB: the angle of reflection of a ray of light must be equal to the angle of incidence of the ray to the mirror.

The simulated system must allow the user to place simulated mirrors in the enclosed area to reflect the light ray to follow a path that will make the ray illuminate all the designated fixed points. his means dynamically placing lines with mouse operations ,such as the mouse_down event, in the path of another line (beam).
As soon as a mirror is placed then the light beam will be reflected and thus change course.

Implementation Hints
Design two classes e.g. clsBeam and clsMirrors. Also try randomly generating the points. Although I've tried using it, it seems I have no control over its movements.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Here is a brain teaser that I couldn't figure out. Can you help me:
    :
    : The Scenario
    : In an enclosed area (your form), there should be located a number of
    : points (no more than 4) through which a ray of light must pass. The
    : light ray emerges in a specific direction from a fixed point.
    : The light is then deflected by reflection using a suitable number of
    : plane mirrors.
    : NB: the angle of reflection of a ray of light must be equal to the
    : angle of incidence of the ray to the mirror.
    :
    : The simulated system must allow the user to place simulated mirrors
    : in the enclosed area to reflect the light ray to follow a path that
    : will make the ray illuminate all the designated fixed points. his
    : means dynamically placing lines with mouse operations ,such as the
    : mouse_down event, in the path of another line (beam).
    : As soon as a mirror is placed then the light beam will be reflected
    : and thus change course.
    :
    : Implementation Hints
    : Design two classes e.g. clsBeam and clsMirrors. Also try randomly
    : generating the points. Although I've tried using it, it seems I have
    : no control over its movements.
    :
    The first step of a project like this is to figure out the mathematics involved. You first need to be able to perform the calculations on paper before putting them into code. For this project you'll need to be able to calculate the angle of an outgoing beam, which exits an arbitrarily placed mirror and has an arbitrary incoming light beam as source. This function will form the heart of your simulation.
    As for the data structure. The beams can best be described as a linked list, with each having a mirror at the end points of each beam. The source can be a subclass of the mirror, just like the sides of the form. This way the design of the clsBeam is simple and you let the polymorphism of OO-design handle the various elements. A linked list also helps you in splitting and merging the beams, when the user places/(re)moves a mirror.
    At this stage you have a working simulation of a beam of light striking an arbitrary of placed mirrors. All what is left to do is to check if the beam strikes a certain point. This is again a purely mathematical problem. The easiest way to solve this is to write the beam as a 1st order equation and then calculate one of the coordinates of a point on that line with the other coordinate of the fixed point in question; i.e. calculate a point (x_f, y2) using the beam equation for a fixed point (x_f, y_f). If the beam strikes the fixed point (x_f, y_f), then y2 equals y_f.
Sign In or Register to comment.