[Oberon] Oberon-7 - Circle Segments
Jörg
joerg.straube at iaeth.ch
Wed Feb 20 15:54:21 CET 2019
Okay, taking your comment into account, we could use the formula c := (r * 2521 + 1455) DIV 2911; (INTEGER arithmetic)
The error 2521/2911 – sqrt(3)/2 = 1.7 x10^-8. That’s smaller than the machine epsilon of Oberon REALs ☺
br
Jörg
Von: Oberon <oberon-bounces at lists.inf.ethz.ch> im Auftrag von "John R. Strohm" <strohm at airmail.net>
Antworten an: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Datum: Mittwoch, 20. Februar 2019 um 15:20
An: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Cc: <oberon at lists.inf.ethz.ch>
Betreff: Re: [Oberon] Oberon-7 - Circle Segments
Looks like a first-order Taylor series expansion.
The assumption is that you are underflowing on the second term.
>From a signal processing point-of-view, you are generally better off calculating to the maximum precision you have available, including the (appropriately-scaled) rounding, and THEN truncating down to your final desired range.
Also, division is usually frowned upon in DSP work, because DSP chips don't usually have hardware dividers. They do have single-cycle hardware multipliers.
--John
--- joerg.straube at iaeth.ch wrote:
From: Jörg <joerg.straube at iaeth.ch>
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] Oberon-7 - Circle Segments
Date: Wed, 20 Feb 2019 13:37:01 +0100
Tomas
Just for completeness: ☺
The formula c := (r * 181 + 104) DIV 209; [now with correct rounding] calculates the HourTicks absolutely correctly for all circles with radius “r” up to 780 pixels.
The formula c := (r * 71 + 41) DIV 82; is correct for circles with radius “r” up to 140 pixels. For larger circles it’s good as well, but sometimes off by one pixel.
br
Jörg
-- Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-- Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190220/beb1f832/attachment.html>
More information about the Oberon
mailing list