convert sin input so it takes degrees

Ameqc's icon

im using the sin object and i forget all that garbage to do with sine, im used to just using a degree input for anything like that.
so basically the sine object takes a floating-point input and ouputs the result in radians, so 0.6 outputs 0.565, i want to be able to put in the degrees and have it output the value in radians. so if i input 90, it outputs 1.0.

seejayjames's icon

you need to use [scale] on your input, which should be in radians (because pi = 3.14159 will give you 0 = 180 degrees, 2pi = 0 = 360 degrees).

try

[scale 0 360 0. 6.2831852] // 0-360 degrees scaled to 0 to 2pi

you can use [% 360] before this, to ensure that degree inputs like 385 will wrap back to 25, or you can just set min 0 and max 360 on your number box input.

Peter McCulloch's icon

Minor point: you don't even need the modulo operation, since it's just a linear mapping and sin will treat 3*pi the same as 1*pi. (e.g. 720 with a lin mapping will be 4*pi which is 0)

Ameqc's icon

thanks

seejayjames's icon

ah of course, trig periodicity... doh ;)

though with most other functions you may need to be sure things wrap.

and [scale] vs. [zmap], there is a difference regarding out-of-range values which may be of interest...

keepsound's icon

Try this

Max Patch
Copy patch and select New From Clipboard in Max.