Trouble Translating Spherical Coordinates from Desmos 3D to Grasshopper

Hi all!

This is a followup to Spherical Coordinates in Grasshopper?

I’m having issues translating my functions from Desmos 3D graphing calculator into rhino. I was able to get the graph I was having issue with from the previous post inro Rhino, see the attached 3dm and gh files. But, when I moved on to more complex functions to graph, it does not look like what Desmos had plotted.

What Desmos plotted

What Grasshopper plotted

For the green surface, it seems to me that one side of the surface is upside-down, but any attempts to split it and correct it fails because the surface is open at that region. And as for the function below that, line 58 in Desmos, I get a “Division by zero” error in Grasshopper, even after triple-checking the parenthesis.

I’ve been stuck on this problem for days and I don’t know what I missed. Any help figuring this out would be greatly appreciated. Thank you very much!

Spherical Coordinates.3dm (13.7 MB)
Spherical Coordinates.gh (28.7 KB)

Hello
this is working as expected if you follow the good equation.
From what you asked you look at this equation
image
Phi has a range form [0 PI] but for Grasshopper coordinate and most of the sytem I know it is [-pi/2 to Pi/2] => so I remap the angle from [0 pi] to [-pi/2 pi/2] not in the equation just for the viewing. This angle is Elevation, Z angle in GH

Strange thing you show this equation in GH that is this one


It is logical that there is a division by 0 because of the Sinus. You can begin at say 0.001 but 1/sin(0.001) will be very big !!!
Second not logical thing you have this equation
image
But you feed it with Phi [0 PI] but it is writte, [2/3PI] !!!

Another not good thing


XY angle (azimuth, bearing …) is [0 2PI] and Z angle [-pi/2 pi/2] (elevation, and you mismatch the angles …

So many many errors.
Spherical Coordinates LD.gh (11.8 KB)

Hi Laurent! Thank you so much for the reply!

Phi has a range form [0 PI] but for Grasshopper coordinate and most of the sytem I know it is [-pi/2 to Pi/2]

Man I wish I knew how to code so I can understand how these 3D graphing calculators work.

so I remap the angle from [0 pi] to [-pi/2 pi/2] not in the equation just for the viewing. This angle is Elevation, Z angle in GH

What I’ve notice right away is that upon fixing this in my script, the geometry is upside-down compared to what Desmos produced. The fix is a simple Negative component but another thing is that the blue geometry is not closed. In fact, neither of the geometries in the script are closed. Not much of a big deal to me but the real issue is this:

It is logical that there is a division by 0 because of the Sinus. You can begin at say 0.001 but 1/sin(0.001) will be very big !!!

Somehow, while fixing my script, the divide by zero error cleared itself! Thanks to you, Laurent, I was able to make a little progress, but the updated Grasshopper Script is now not matching the blue surface plotted by Desmos. See below:

And this is what Grasshopper plotted

If you were to play around with this in Desmos (Here is the link), you’ll quickly see that this particular function goes to infinity. Perhaps this has something to do with why Grasshopper is plotting it incorrectly? I’m not sure how you can restrict the Z-value of a function that goes to infinity in spherical coordinates beside splitting it with a plane. Again, thanks for providing your insight!

Spherical Coordinates LD_Updated.gh (28.5 KB)

Hello
still errors, you must be more careful.
I just look at Desmos and it is clear that angles are not exactly what I thouht. It was hard to guess without documentation. See there

So

f(theta = 0 ) = -pi/2 (Zel Grasshopper)
f(theta = pi ) = pi/2 (Zel Grasshopper)
=>
z elevation =-pi/2 + theta

2nd and last error


(cos(0.5phi)/2sin(1.25phi)^2)
not equal to
cos(0.5
phi)/(2sin(1.25phi)^2)

cos(0.5*phi) \over {2*sin(1.25*phi)^2}

To deal with the infinity just not begin at 0 but 0.1 for example

Spherical Coordinates LD_Updatedv2.gh (17.5 KB)

Thank you Laurent! I was able to get it working! I will keep in mind that it is Phi that restricts the Z height.

Here’s another function that Desmos plotted

And here’s what Grasshopper plotted

Again, thanks so much for the help!

Spherical Coordinates LD_Updatedv2.1.gh (31.4 KB)

1 Like