Deutsch   English   Français   Italiano  
<vf1ug0$8qpm$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.fortran
Subject: Angle Units For Trig Functions
Date: Sun, 20 Oct 2024 03:47:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vf1ug0$8qpm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 20 Oct 2024 05:47:13 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bebb5afd8d6b363c1d85744b8b6ba226";
	logging-data="289590"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19bpUT257UhRBzrbNBujcMp"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:N45Er92Way1jZHEuEirmiQxwuOQ=
Bytes: 1872

I see that the Fortran 2023 spec has added a bunch of parallel trig 
functions that work in degrees.

I find this sort of thing unnecessary. It seems conventional to add 
functions for converting between degrees and radians, but a simpler way is 
to simply define a conversion factor for each angle unit. One conversion 
factor is simpler than two functions for each angle unit.

So trig functions always work in radians. Supposing we have

    real, parameter :: DEG = PI / 180
    real, parameter :: CIRCLE = 2 * PI
    real, parameter :: RAD = 1

Then

    sin(x) -- sin of x in radians
    sin(x * DEG) -- x is in degrees
    atan2(y, x) -- arctangent is in radians
    atan2(y, x) / DEG -- arctangent is in degrees

and we can furthermore have equivalences like

    sin(90 * DEG) = sin(0.25 * CIRCLE) = sin(PI / 2)

(to within rounding error, of course)

and it is easy enough to add other units, e.g.

    real, parameter :: GRAD = PI / 200

Anybody remember those?