Re: Comparing the absolute values.



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

.



Relevant Pages

  • Re: Geometry with parabola...
    ... You don't really need the *slope* ... because you need to consider separate ... drawing, not for *any* A and B, anywhere on the parabola. ... that was not technically perfect? ...
    (sci.math)
  • Re: Geometry with parabola...
    ... You don't really need the *slope* ... because you need to consider separate ... You should consider that parabola is the union of the *TWO* curves ... drawing, not for *any* A and B, anywhere on the parabola. ...
    (sci.math)
  • Re: Comparing the absolute values.
    ... I still need it for calculate the slope, ... each time I increment the most-varying coordinate. ... negative and then choose the correct algorithm, but I'd like to avoid ...
    (comp.lang.asm.x86)