Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I implemented/copied the wu line algorithm from pseudo-code on wiki-pedia and other places.

When drawing a sine wave it breaks down at the point where the line changes from y dominant to x dominant (or vice versa). (I did not copy the endpoint code because it looks terrible and I do not need them for my purposes. )

Does anyone know a solution for this issue? If not I will modify the algorithm myself to get it to work. I am just curious if someone else has run into this and knows exactly how to fix it. Is it possible to implement without the lines being globally aware of each other? Or is this why drawing API's implement moveto and lineto functions?

The pseudo code

share|improve this question

Are your pixel pairs really covering the line points? You appear to have an off-by-one error in your algorithm implementation.

I suggest plotting the aliased version of your curve and superposing the two images, maybe using two separate colour channels. You will probably see where the error lies. Or you could post some code for double checking.

share|improve this answer
Yea the issue is fractional points....and perhaps lines that are less than one pixel long. There is a rounding error so when the next line is drawn in certain cases it draws it one off from the the last endpoint. I am working on it. – eat_a_lemon Apr 24 '11 at 0:25

Your Answer


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.