comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Many overlook the possibility sin(x,360.0) ?
Date: Wed, 3 May 2017 09:18:21 +0200
Date: 2017-05-03T09:18:21+02:00	[thread overview]
Message-ID: <oec07s$an6$1@gioia.aioe.org> (raw)
In-Reply-To: 518cca79-b172-4e96-bca0-b6491cd3c013@googlegroups.com

On 03/05/2017 06:12, reinert wrote:

> Here is an attempt to make clean code plotting an approximation of a circle
> (using two arguments for cos and sin):
>
>    for i in 0 .. 35 loop
>        vertex(radius * (cos (real (i), 36.0), sin (real (i), 36.0)));
>    end loop;

I would rather:

declare
    Points   : constant := 36;
    To_Angle : constant Real := 2.0 * Pi / Real (Points);
begin
    for i in 0..Points - 1 loop
       declare
          Angle : constant Real := Real (I) * To_Angle;
       begin
          vertex (radius * (cos (Angle), sin (Angle)));
       end;
    end loop;
end;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2017-05-03  7:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-01  5:22 Many overlook the possibility sin(x,360.0) ? reinert
2017-05-01  8:50 ` hreba
2017-05-01 17:46 ` Nasser M. Abbasi
2017-05-01 20:04   ` Dmitry A. Kazakov
2017-05-01 20:46     ` Shark8
2017-05-02  6:37       ` reinert
2017-05-02  8:35         ` Dmitry A. Kazakov
2017-05-03  4:12           ` reinert
2017-05-03  7:18             ` Dmitry A. Kazakov [this message]
2017-05-08 17:37               ` reinert
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox