 # Geometry :

Subject: [ggl] Finding intersection points of a ray and polygon?
From: Elvis Stansvik (elvstone)
Date: 2010-02-22 10:50:29

Hello GGLers,

For a very small high-school project I'm making a simple Qt
application that should let my teacher illustrate the Law of
refraction  to his students.

The idea is to let the user of the application place a set of simple
bodies (polygons) with optical properties into a scene and then let a
ray of light pass through them. With ray I mean a line which is finite
in one direction but infinite in the other.

This requires me to find the ray's first intersection point with a
polygon. As I don't have quite a lot of math under my belt, and the
project is very small and done under time constraints I started
looking for a computational geometry library and found Boost.Geometry
which seems to fit the bill.

Now my question is; can Boost.Geometry help me find the first
intersection point of a ray and a polygon, and after that also give me
access to the polygon edge that was hit? (I will need the angle of the
edge to do the refraction calculation).

I'm very open to to ways in which I can simplify my project, as I only
have a few weeks. Just using simple convex polygons for the optical
bodies would be OK, and also using a line segment of finite length

Any pointers and tips to examples besides the one on the User Wiki and
reference documentation are much appriciated. My C++ proficiency is
OKish and my template programming knowledge definitely rusty ;)

Finally, congrats to getting GGL into Boost proper.

Best regards,
Elvis Stansvik

 http://en.wikipedia.org/wiki/Law_of_refraction

Geometry list run by mateusz at loskot.net