|
Geometry : |
Subject: [ggl] Re: Finding intersection points of a ray and polygon?
From: Elvis Stansvik (elvstone)
Date: 2010-02-22 18:05:06
2010/2/22 Elvis Stansvik <elvstone_at_[hidden]>:
> 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 [1] 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
> instead of a ray.
>
> 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
>
> [1] http://en.wikipedia.org/wiki/Law_of_refraction
>
I realized after sending my mail that I have an additional question:
For my application I would need to know if (at the intersection point)
the ray is passing into or out of the polygon. Can Boost.Geometry give
me this information?
Regards,
Elvis
Geometry list run by mateusz at loskot.net