Closed Thread Icon

Topic awaiting preservation: Math functions returning incorrect values? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23951" title="Pages that link to Topic awaiting preservation: Math functions returning incorrect values? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Math functions returning incorrect values? <span class="small">(Page 1 of 1)</span>\

 
Hebedee
Paranoid (IV) Inmate

From: Maryland, USA
Insane since: Jan 2001

posted posted 11-07-2004 22:46
code:
angle = 45;
alert(angle + " degrees: sine: " + Math.sin(angle) + "; cosine: " + Math.cos(angle));



That code turns different values. The sine and cosine of 45 degrees are (if I recall correctly) equal.

Is there a history of this in JavaScript, or are my paltry trigonometry skills failing me, or neither?

I have been considering doing manual sines and cosines to see what happens.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-07-2004 23:18

the trigonometric functions in JS, and actually in most computer languages , are in radians.

Hebedee
Paranoid (IV) Inmate

From: Maryland, USA
Insane since: Jan 2001

posted posted 11-08-2004 00:02

Ah hah! I found no mention of that when I looked up the functions. Thank you very much.

(Edited by Hebedee on 11-08-2004 00:05)

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 11-09-2004 20:49

It's not surprising that you didn't find any documentation on it - mathematically, radians makes much more sense than degrees or (new-)grades, so if you talk about angles, you should always assume radians unless otherwise specified. The reason is because radians are directly derived from the definition of the geometric shape (circle) (radians are derived from SI as Lenght/Length - or in units m/m, which means it's a dimensionless unit), while degrees are further removed.

Another way to say it: Radians are directly derived from the geometric shape and describes the relation between the radius (Length, unit m) and the circumference of a circle (Length, unit m, always 2×PI×radius), while degrees are just an arbitrary unit for circumference which does not have any direct correlation other than to the circumference.

--
var Liorean = {
prototype: JavaScriptGuru.prototype,
abode: "http://web-graphics.com/",
profile: "http://codingforums.com/member.php?u=5798"};

« BackwardsOnwards »

Show Forum Drop Down Menu