Grasshopper

algorithmic modeling for Rhino

There is something strange about taking the squareroot of 0, in case the 0 returns as result from a former operation.

The different components seem to treat the problem in various ways. Seems to be something about rounding, since filtering input through a textpanel can make the equation of sqrt(0)=0 solvable again.

And how to understand the {...,...} result of the negative sqrt? Shouldn´t this be <null>?

Views: 1200

Replies to This Discussion

Hi Phillip,

Square root of a negative number can be represented as a complex number. A complex number is written in the form of a + bi where a and b are real numbers and i = square root of -1. In Grasshopper, it is shown as {a,b}.

For example, sqrt(-4) = sqrt(4 * -1) = sqrt(4) * sqrt(-1)  = 2 * i = 0 + 2i. Therefore, this will be {0, 2} in Grasshopper.

Hi Sridevi,

thanks! Now I understand.

So if this is according to a rounding error, I wonder why Expression doesn´t return the same (wrong) complex as the multi-component set up...

It seems that unlike the square-root component, the expression component is not able to handle the square-root of negative numbers. So even though cos(t) appears to be precisely 0.5, it is actually greater than 0.5 (something like 0.50000000001....). Therefore, in the expression component, 1-2*cos(t) results in a negative number (-0.0000000xxx), whose square-root results in the NaN.

Some extra information :)

I just found out that NaN stands for Not a Number, and one of the operations that results in a NaN is square root of a negative number.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service