2008年2月29日 星期五

PKU 1031 - Fence

The main problem is to ask the total illumination illuminated to a polygon shaped fence from a point light.

It is given that the intensity of certain point is given by where is a constant and is the point-point distance.

As the fence has height , assume that we are going to illuminate certain slice with area , the illumination is given by . The question asks about where is the area illuminated by the lamp.

The problem is not difficult to solve but, you need to deal with calculus.
Imagine a lamp point shines on a fence segment with height .

Case I: 's projection, is on
Let the point to segment distance be . Now that we are going to calculate the intensity of .

By trigonometry,

By Pythagors' Theorem,

Therefore,

By integration,





Note that .
You can get the similar result of the side by the following expression

where
Therefore the total intensity of shines on is given by

where

You may see that the result is simply dealing with the included angle between the light source and the fence segment.

Case 2: 's projection, is not on
By case 1, the result still holds (Just complement angle only).

Since the inclination of the fence to the lamp does not matter, the final conclusion is that: from the point of view of the lamp, how much angle the polygon is inclined to it, the result is simply by using the above equation.

Be careful:
  • Use acos(-1) instead of pasting constant from wiki as
  • Determine if a point is inside a general polygon
  • Even though the point is outside the polygon, the view angle can still be

Startup - Way to write

First time to blogger, hello world!
Though a late start, I will put everything related to programming and algorithm here (most probably the problem I have worked on) for my and you guys future reference.