MoI discussion forum
MoI discussion forum

Full Version: Parametric design in MoI?

Show messages:  1-8  …  849-868  869-888  889-908  909-912

From: bemfarmer
6 Apr 2022   [#909] In reply to [#908]
The javascript sin(angle) gives the correct result for angle in radians.

For 117 degrees, multiply by (PI/180) yields 2.042... radians. Javascript sin(2.042...) = .891..., which agrees with your calculator set to DEG.

James is correct, in that javascript sin(117) treats 117 as radians, NOT degrees.

Max is using square brackets [ ] for the trig. The math in Max's node is done using Javascript Math functions. Javascript version ES5, NOT ES6.
(I think sin() is the same as sin[] in the node (???))

- Brian
From: bemfarmer
6 Apr 2022   [#910] In reply to [#908]
Google search often yields responses on stackoverflow, which can be helpful, (if understandable)

See last answer here:
https://stackoverflow.com/questions/13975745/the-fastest-way-to-get-current-quadrant-of-an-angle

The degree angle theta needs to be converted to radians, to use the Javascript Math.sin[radianAngle]. (Max removed the need to use Math. in front of sin)

if sin[theta*PI/180] >= 0 , then output is +1.

if sin[theta*PI/180] < 0 , then output is -1.

So compare does seem to be useful. The Sine provides similar benefit to using modulus of +/- angle. Javascript Modulus (%), of angle could be used instead of Sine...

- Brian
From: Psygorn (DRILLBIT)
6 Apr 2022   [#911] In reply to [#909]
Thank you Brian,

Now, I got it!

:)
From: Psygorn (DRILLBIT)
6 Apr 2022   [#912] In reply to [#910]
Thank you again, Brian,

Your explanation helped a lot!

I was able to solve the problem and here are the results:

http://moi3d.com/forum/index.php?webtag=MOI&msg=10641.16

I would be happy to know your opinion about it! (I mean could I do it better?)

Show messages:  1-8  …  849-868  869-888  889-908  909-912