0
\$\begingroup\$

I am trying to implement a simple beam tracing simulation. Basically it models the path of a beam within a pipe:

enter image description here

In the picture, the beam starts emitting from p1, hitting the boundary at p2 and reflects to p3. I was thinking of the algorithm of such a system. Assuming that all equations of the 2 blue curves are known:

1) Get the parametrized representation of original line from p1, say p1(t).

2) Equate p1(t) with both curves.

3) Find the first intersection p2, determined by the lowest value of t.

4) Get the normal at the intersection and get the equation of the reflected beam, p2(t).

5) Equate p2(t) with both curves, eventually solving for p3.

6) Repeat for as many iterations as needed.

My question is that, is there more sophisticated way of doing this? Or is there a library out there that implements this kind of functionality directly? Currently I am using C#, and looking into WPF and also OpenGL, but I am afraid that OpenGL may be too low level (?) and requires much code to achieve this.

\$\endgroup\$
  • \$\begingroup\$ Yes, OpenGL is a very low-level drawing api. Calling it a "drawing api" is, itself, pretty misleading, it takes a great gob of OpenGL calls before you can even see a line. :D \$\endgroup\$ – david van brink Jan 22 '15 at 4:32
  • 2
    \$\begingroup\$ How much more sophisticated do you want it to be and what for? What you have described is a pretty simple algo, especially if all you have is just a pipe. \$\endgroup\$ – Kromster Jan 22 '15 at 5:21
  • \$\begingroup\$ I should not have used the word 'sophisticated', what I meant is that is there a better method of drawing this. \$\endgroup\$ – John Tan Jan 22 '15 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.