Parametric design in MoI?
 1-7  …  868-887  888-907  908-912

Previous
Next
 From:  Psygorn (DRILLBIT)
7713.908 In reply to 7713.907 
>> It IS working properly...given that sin(117) / 2 = -0.34, the floor value will be -1

Hello James, but I think sin(117) = 0.891 even calculator says that!



I assume the value of sin is not calculated in Degree? (I think it is in Rad)

How can I get 1 for values of A from 0 to 180, and -1 for values of A from 181 to 360? in Degrees.
for example I thought if I use : 1+( 2 * floor function of (sin (a)/2)) I could have 1 for 0<a<180 and -1 for 180 <a<360

.>>If you imagine a point revolving around a circle, at any point the sine of the angle: sin[a]
equals the y component / radius, so regardless of the radius the result will be 0 on the horizontal axis
and 1 & -1 at top & bottom of the vertical axis respectively, and the points in-between will give a result
ranging from -1 to 1

Luckily, I know about it! and I know if we imagine a circle and divide it by the largest horizontal segment (it's horizontal diameter) then "sin(an angle in the upper semicircle)" would be positive and "sin(an angle in the lower semicircle)" would be negative. :-)

I just don't know how to do it in Nodeeditor, How to turn all positive values of sin to 1 and negative ones to -1.

Edit: Dear James I always had struggle where t use RAD and where to use Degree!

EDITED: 6 Apr 2022 by DRILLBIT

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7713.909 In reply to 7713.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
7713.910 In reply to 7713.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

EDITED: 6 Apr 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Psygorn (DRILLBIT)
7713.911 In reply to 7713.909 
Thank you Brian,

Now, I got it!

:)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Psygorn (DRILLBIT)
7713.912 In reply to 7713.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?)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages:  1-7  …  848-867  868-887  888-907  908-912