Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

is it possible to calculate shadow areas of buildings or simulate shadows of buildings in a city, using the heights of these buildings and the sun angle and azimuth? the basic light tracing concept using trigonometry is known. But the Problem is how to find away to come up with simulated shadow of group of buildings in one place.

share|improve this question
2  
Cool question. I wonder though if you might get better initial responses from the new Physics StackExchange? –  Peter Boughton Nov 10 '10 at 10:55

3 Answers 3

Yes, this is a matter of projecting the geometry of the buildings onto a shadow plane along the sun angle, and then computing the union of the resulting polygons. This gives a single polygon that you can then get the area of by simple triangle subdivision. All of these features are actually built into your graphics card these days.

If your buildings are non-polygonal and you need a precise answer you're out of luck unless you can model them mathematically, but really that's a rare case these days--everything's built of polygons, and/or you can get away with an approximated answer.

For a specific solution, I'd recommend asking this question on Stack Overflow.

share|improve this answer

Yes, of course this is possible. It is called ray tracing.

Being old and grey means I can remember when ray tracing was exclusively the province of large supercomputers. It is now routinely assigned as an undergraduate computer graphics class programming assignment, and the results can be STUNNING.

Take a look at this, for some examples of what the kids are doing these days.

share|improve this answer
    
I'm pretty young yet, but I've read a bit about what PCs used to be capable of, and yes, it's pretty amazing how far we've come. –  Michael K Nov 10 '10 at 13:27
    
I'm still waiting for real-time raytracing. We're getting close! –  Alex Feinman Nov 10 '10 at 17:54

Are you actually ray-tracing? If so, you backtrace from the point being rendered to the light source. If it intersects one of the buildings, its in a shadow.

If you are using OpenGL/DirectX for real-time graphics, there are other solutions - look around online as thats a fairly big topic.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.