Sin() and Cos() to optionally support degrees...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Kale wrote:
djes wrote:I prefer differents dedicated functions for this reason :

"Sin" and "cos" in radians
"Sinq" and "cosq" or anything else, like "sind" and "cosd" for degrees.
You misunderstand, my request was for an optional unit parameter to allow sin and cos to work with degrees. There is no need for seperate commands because when compiled the two different versions can be use behind the scenes. Just like the Plot(x, y) and plot(x, y, colour) commands where the first is not accelerated but the second is.
Ok for that :)

Example : cos(angle,[deg]) : if deg==true, angle is in degrees, else in radians
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

That would be indeed useful. An optional parameter which Kale mentioned firstly in his post
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

imho this should be adopted on all maths commands - some like:

Code: Select all

Result.f = ACos(Value.f,#PB_Degrees)
Returns the Arc-Cosinus of the specified value. Value.f must be between -1 and 1, the result will be in degrees

or alternatively do like the 8-bits did. Have a command to shift all future maths commands to degrees and vice versa.

Code: Select all

Deg()
All future maths commands use/return in degrees.

Code: Select all

Rad()
All future maths commands use/return in radians.

The default being radians.

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

This thread contains a lot of good ideas! :) But i guess the whole consensus of opinion is that it would be nice for the math functions to support both in some way, i guess the implementation is up to Fred & co. :D
--Kale

Image
Post Reply