Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What is the significance of Bresenhams Line of Sight algorithm in chasing and evading in games?

As far as i know and implemented this algorithm calulates the straight line between two given points. However while implementing it in game development i stored the points calculated using this algorithm in an array.Then im traversing this array for chasing and evading purpose. This looks to be working good with some angles only.In an pixel based environment/tile based.

What if there are some obstacles added in the paths of the two points? then this algorithm will not work right?

How well can we use the Bresenhams Line algorithm in game development?

share|improve this question
    
wouldn't a cone be a better primitive than a line? –  Will Mar 1 '11 at 11:06
    
i dint understand –  GamDroid Mar 1 '11 at 11:11
    
line drawing is not the same as line of sight. The question is about a non-existent algorithm. Sounds like the questioner is not using the line drawing algorithm to draw lines, but instead plot "steps" for an AI. For this, there are many better solutions than using a line drawing algorithm. –  Richard Fabian Mar 1 '11 at 16:22
add comment

1 Answer

up vote 2 down vote accepted

Bresenhams line algorithm was very useful in history (history of computer graphics), where was need of drawing lines without using floating point operations, because integer operations are faster (was faster). This is not today problem. In cpu is integrated math co-procesor (till intel 486), there is SSE unit and also GPU computes floatng points. There are not many useful usages of Bresenham today. But still. It is very interesting historicaly and it is beatiful algorithm to study.

share|improve this answer
2  
Actually, I'd say that Bresenham still has its share of uses, though they're admittedly more sparse. It's easy to modify the algorithm to iterate over all the 'pixels' covered by a line, and this can actually be immensely useful for things like the original poster's 2d line-of-sight raycasting question, if your object data is organized in a simple spatial grid and you need to know which grid cells to check for possible colliding objects. –  Steven Stadnicki Mar 1 '11 at 20:16
    
Yeah. Also for 3D grid traversal (if edited to 3D) and we can continue. But there is no big (but there is question what is big) performance benefit in comparison to using vector abstraction with float operations. –  Notabene Mar 1 '11 at 21:51
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.