3
$\begingroup$

I was trying to complete my answer for this question. I'm creating an XYZ Math Surface via Add > Mesh > Math Function > XYZ Math Surface using the following parametric equations:

X: (g*f)/16*(3/2*((u**2 + v**2)*(1 + (u + v - 1)**2) - 2*(u**2*v**2 - 2*(u*v - u - v) - 1))/(u**2 + u*v + v**2 - u - v + 1)**2) + (sqrt(3)/6*(3*u + 3*v - 2)/sqrt(u**2 + v**2 + u*v - u - v + 1))*f/2
Y: (g*f)/16*(3/2*sqrt(3)*((u**2 - v**2)*(1 + (u + v - 1)**2))/(u**2 + u*v + v**2 - u - v + 1)**2) - (1/2*(u - v)/sqrt(u**2 + v**2 + u*v - u - v + 1))*f/2
Z: (g*f)/16*(3/2*sqrt(2)*((u**2 + v**2)*(2 - (u + v - 1)**2) - (u**2*v**2 - 2*(u*v - u - v) - 1))/(u**2 + u*v + v**2 - u - v + 1)**2 - sqrt(2)) - (sqrt(6)/3*(-1)/sqrt(u**2 + u*v + v**2 - u - v + 1) - 1)*f/2

parameters:

U min:  0.00
U max:  1.00
U step: 72
V min:  0.00
V max:  1.00
V step: 72
F:  2.00
G: 0

Which look like this if I'm not mistaken: $$ x(u,v) = \frac{g \cdot f}{16} \cdot \frac{3}{2} \cdot \frac{(u^2 + v^2) \cdot (1 + (u + v - 1)^2) - 2 \cdot (u^2 \cdot v^2 - 2 \cdot (u \cdot v - u - v) - 1)}{(u^2 + u \cdot v + v^2 - u - v + 1)^2} + \frac{\sqrt{3}}{6} \cdot \frac{(3 \cdot u + 3 \cdot v - 2)}{\sqrt{u^2 + v^2 + u \cdot v - u - v + 1}} \cdot \frac{f}{2} $$

$$ y(u,v) = \frac{g \cdot f}{16} \left( \frac{3}{2} \cdot \sqrt{3} \cdot \frac{(u^2 - v^2) \cdot (1 + (u + v - 1)^2)}{(u^2 + u \cdot v + v^2 - u - v + 1)^2} \right) - \frac{1}{2} \cdot \frac{(u - v)}{\sqrt{u^2 + v^2 + u \cdot v - u - v + 1}} \cdot \frac{f}{2} $$

$$ z(u,v) = \frac{g \cdot f}{16} \left( \frac{3}{2} \sqrt{2} \cdot \frac{(u^2 + v^2) \cdot \left(2 - (u + v - 1)^2\right) - \left(u^2 v^2 - 2 \cdot (u v - u - v) - 1\right)}{(u^2 + u v + v^2 - u - v + 1)^2} - \sqrt{2} \right) - \left( \frac{\sqrt{6}}{3} \cdot \left( -\frac{1}{\sqrt{u^2 + u v + v^2 - u - v + 1}} - 1 \right) \right) \cdot \frac{f}{2} $$

When I try to map the nodes in a custom node group named XYZ-Surface, I get a surface that is lower on the z-axis. They should be coinciding with each other:

enter image description here

All the other surfaces I made worked perfectly except this one. Since it is the Z that is shifted, the problem must probably lie in the Z equation. However, no matter how many times I recheck the node tree, I can't understand why it's not positioned correctly. I have checked this several times now to no avail forcing me to seek for extra eyes to look at this.

enter image description here

Here's what's inside the main Geometry Nodes modifier:

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ It must be something very simple for sure but I just can't spot the error I made. EDIT: Maybe not as simple as I thought since I discovered I have the same shifted problem for the bottom surface. $\endgroup$
    – Harry McKenzie
    Commented Jun 12 at 9:26
  • 1
    $\begingroup$ Jeeeez .. this is hard labour! Your existing answer is heroic :) $\endgroup$
    – Robin Betts
    Commented Jun 12 at 18:34
  • $\begingroup$ Is there really no way to just write a function in Geometry Nodes? We need to use a separate node for every single instance of every mathematical operation? That makes debugging something like this SO difficult... $\endgroup$
    – Lawton
    Commented Jun 12 at 19:03
  • 1
    $\begingroup$ @HarryMcKenzie Node Expressions crossed my mind. I didn't realize it had been updated to include GN. It's by Rich Sedman, of this parish, who, (I'm sure he won't mind me saying,) has been a primary example for me to try to emulate, here on BSE. :) $\endgroup$
    – Robin Betts
    Commented Jun 13 at 7:34
  • 2
    $\begingroup$ @RobinBetts hey guys good news look what I've found. github.com/WannesMalfait/Blender-Add-ons/releases I was able to immediately copy all the python equations and paste them to instantly create the node tree. wow should have known this earlier and saved so much time XD $\endgroup$
    – Harry McKenzie
    Commented Jun 13 at 10:25

1 Answer 1

3
$\begingroup$

There is an error in transposing the equation from XYZ Math Surface code to LaTeX. The last part of $z(u,v)$, computed in the frame "Z Equation Term 2", is written as: $$ z(u,v) = (...) - \left( \frac{\sqrt{6}}{3} \cdot \left( -\frac{1}{\sqrt{u^2 + u v + v^2 - u - v + 1}} - 1 \right) \right) \cdot \frac{f}{2} $$ whereas it should be (from the pseudo-code): $$ z(u,v) = (...) - \left( \frac{\sqrt{6}}{3} \cdot \frac{-1}{\sqrt{u^2 + u v + v^2 - u - v + 1}} - 1 \right) \cdot \frac{f}{2} $$ To debug, taking advantage that $g=0$, I specified $u=v=0$ for every grid point, yielding constant functions easier to track, after I noticed that the shift is almost the same at the four corners.

$\endgroup$
4
  • 1
    $\begingroup$ Side Note: I checked the rest and I could not find any mistake in the transposition. I did not checked the GN graph however... But after correction of the "Z Equation Term 2" frame, both surfaces are superimposed. $\endgroup$ Commented Jun 12 at 19:48
  • 2
    $\begingroup$ This is a video about Harry and Stef: youtube.com/watch?v=M61xXdVlP5o $\endgroup$ Commented Jun 12 at 20:08
  • 1
    $\begingroup$ oh my.. those parenthesis killed me lol. thank you so much! nice video btw! :D $\endgroup$
    – Harry McKenzie
    Commented Jun 13 at 3:01
  • 2
    $\begingroup$ A lesson in elegant debugging! Now I know there is such a thing :) @MarkusvonBroady :D great find! The copywriters earned their bucks, for once. $\endgroup$
    – Robin Betts
    Commented Jun 13 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .