first programs

From: Douglas Quebbeman <dhquebbeman_at_theestopinalgroup.com>
Date: Tue Jan 16 14:42:33 2001

> My first useful program was a graphical alarm clock. I'm a dropout and so
> missed math education beyond arithmetic. This is why I do all my agebraic
> problems linearly as you do in programing. I still don't understand how
> and why algebra is done the way it is in schools. Boolean algebra makes
> so much more sense to me.

Trig smoothly describes the world as it really is-
  the approximations you independently discovered describe the
  world well enough to fool human perception.

More on this below.

> Anyway, I was trying to plot the face of a circular clock. First I tried
> using PI as the base for the plotting and my clock's face came out wierd
> and incomplete. After messing with the program for some hours I realized
> that OF COURSE a circle derived from pi was going to be incomplete because
> PI is irrational. No matter how many digits after the dicimal you use, you
> will never get a complete circle, just a progressively less incomplete
> one. Duh. Back to the drawing board.
>
> I started hitting the trig functions looking for an answer and hit on
> Sine/cosine as the way to do it. Educating yourself is hard and you often
> have to backtrack like that.

You only have to look at AutoCAD to see how crappy a circle looks when
derived by trigonometric evaluation; it wouldn't be that way if there was
enough precision available, but there never seems to be...

So, a guy named Bresenham came up with a click way to generate a circle,
and it was improved upon by another computer scientist named Michener.
it takes advantage of the 8-way symmetry a circle will have when created
in the approximate fashion that pixels arranged in a Cartesian grid yields.

The algorithm generates the points for a single octant of the circle, then
generates the other seven octants by (essentially) changing the sign of
the values for the first octant. The virual result are perfectly symmetric
approximations of circles.

There's also an algorithm I saw written up in Byte years ago for doing
parabolas; the author referred to it as the Variable Duty-Cycle Algorithm.

For a dummy radar-display I hacked up, to handle the sweep line, I
simply at program start-up pre-computed all the data for the lines
in each position of the sweep; I did it with trigonometric evaluation,
but stored the daata in an array and just puked it out at runtime.

But just like with the calculator, it helps to understand the
fundamentals before trying to implement a solution sans science.
 
OTOH, not knowing the fundamentals has failed to stop many a man...

...OOPS! And women, too, I guess (apologies to Megan and Allison!).

Regards,
-dq
Received on Tue Jan 16 2001 - 14:42:33 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:47 BST