Re: Comparing the absolute values.
- From: "Alexei A. Frounze" <spamtrap@xxxxxxxxxx>
- Date: Sat, 7 Jul 2007 21:16:49 -0700
João Jerónimo wrote:
Alexei A. Frounze wrote:João Jerónimo wrote:I want to implement the Basenham's
B*re*senham's
Right............
Bresenham's is not here so I'm safe!... :-)
line drawing algorithm, so I will
need to compare the absolute values of two numbers (because the
slope is calculated by dividing the minor axes by the major axis)...
The beauty of the algorithm is exactly in that it doesn't have any
arithmetic division.
I still need it for calculate the slope, which needs division...
Can you tell us why you need the slope (aka tangent) in this standard Bresenham's line drawing algorithm? It's unnecessary, unless you're doing something else in addition to just drawing a line.
Then, I'll use fixed-point math. If I calculate the slope (which is a
real number between 0 and 1) in a 32-bit register, then I can have a
precision
of 65536 parts of point (i.e. the low word will be used to represent
sub-points with a resolution of X_max*65535 or Y_max*65535). Then I
need a 16 bit register that will be initialized to 0, and to which
the slope will be added, each time I increment the most-varying
coordinate. If the result carried out, then I need to
increment/decrement the least-varying coordinate. I may be wrong, but
as far as I can see there is no fault...
You could do that, but, as I said, it's unnecessary for line drawing. And it will be less acurate because of the round-off error in the slope and very likely slower. What is this complication for?
Alex
.
- Follow-Ups:
- Re: Comparing the absolute values.
- From: João Jerónimo
- Re: Comparing the absolute values.
- From: Phil Carmody
- Re: Comparing the absolute values.
- References:
- Comparing the absolute values.
- From: João Jerónimo
- Re: Comparing the absolute values.
- From: Alexei A. Frounze
- Re: Comparing the absolute values.
- From: João Jerónimo
- Comparing the absolute values.
- Prev by Date: Re: Comparing the absolute values.
- Next by Date: Re: 64bit operations efficiency...
- Previous by thread: Re: Comparing the absolute values.
- Next by thread: Re: Comparing the absolute values.
- Index(es):
Relevant Pages
|