For the prism simulation,
there are two more rays produced each time the main ray touch the prism boundary.
One is the reflected ray and another one is the refracted ray.
So I use two array to record and polt the trace for those rays.
The intensity for all the rays are also calculated.
Up to 20 reflection/refraction rays are traced.
The intensity of the reflected ray is less than 5% so it become very weak.
That is why a [b]show all[/b] check box is added to show all the traces.

For the case of [img]http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=1434.0;attach=1688;image[/img]
The ray enter the prism will create a series of rays.
However, the ray enter the polygon more than once so more sets of rays are needed to trace all possible traces.

Because the simulation also allow user to change number of face for the polygon.
So it is not easy to know how many rays are needed.
It can be done with dynamical allocated memory to solve the problem. However, it is not the way EJS(The tool used to create the simulation) was designed.

I can modify to solved the problem for the above case. However, there might be another bug for another type of problem. It is not easy to design a simulation to fit with too many degree of freedom. I did all this with my spare time.
It will be much easier if we do not need to trace many reflected rays.
Please let me know what you really want to do. What is the purpose of your work so that I can create a simulation better fit with what you need.

Does the following shape is the only case you want to study?
[img]http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=37.0;attach=1686;image[/img]
Please let me know what kind of information you are really intereated in.
What is the purpose for the study?

Do you need to calculate up to 20 reflected rays? Do you need to know information for the intensity for each ray? Do you need reflected ray and refracted ray?
Please describe all the possible cases you want to do.

You only ask one more feature at a time. Please let me know all the information and I will try to help.