We are about to switch to a new forum software. Until then we have removed the registration on this forum.

- All Categories 25.7K
- Announcements & Guidelines 13
- Common Questions 30
- Using Processing 22.1K
- Programming Questions 12.2K
- Questions about Code 6.4K
- How To... 4.2K
- Hello Processing 72
- GLSL / Shaders 292
- Library Questions 4K
- Hardware, Integration & Other Languages 2.7K
- Kinect 668
- Arduino 1K
- Raspberry PI 188
- Questions about Modes 2K
- Android Mode 1.3K
- JavaScript Mode 413
- Python Mode 205
- Questions about Tools 100
- Espanol 5
- Developing Processing 548
- Create & Announce Libraries 211
- Create & Announce Modes 19
- Create & Announce Tools 29
- Summer of Code 2018 93
- Rails Girls Summer of Code 2017 3
- Summer of Code 2017 49
- Summer of Code 2016 4
- Summer of Code 2015 40
- Summer of Code 2014 22
- p5.js 1.6K
- p5.js Programming Questions 947
- p5.js Library Questions 315
- p5.js Development Questions 31
- General 1.4K
- Events & Opportunities 289
- General Discussion 365

Hi everyone,

So I'm doing some work with angles/trigonometry, but for some reason angleMode(DEGREES); does absolutely nothing. If I run angleMode(DEGREES); Math.sin(90); in the console I got the value of sin(90 radians) instead of the value for degrees.

Tagged:

## Answers

just use

;-)

That doesnt seem to work for sin(radians(180)); where you'd expect 0 but you get '1.2246467991473532e-16'

I think that's okay, that's only when you print it out

To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions.

https://www.processing.org/reference/

here is an example for sin(radians(180));

Chrisir

[EDITED]

That seems to be processing code, not p5.js code, but regardless it just doesn't work. Also, I can't use rounding as it would be inconsistent: through some magic or dumb luck things have now magically changed and the values are close to correct but not quite: sin(radians(180)) gives 0.0548036651... while cos(radians(180)) gives 0.9984971...

interesting

probably rounding errors or so

I dunno

;-)

angleMode(): https://p5js.org/reference/#/p5/angleModehttps://Forum.Processing.org/two/discussions/tagged?Tag=anglemode()

An online p5.js sketch using

angleMode()in DEGREES: :bzhttp://Bl.ocks.org/GoSubRoutine/a117ecb16a8b0f939a190f87d3a13267

https://KhanAcademy.org/computer-programming/3d-tutorial-4/1648921303