0

In this question I want to specify a domain of $0<=x<=1$ and $0<=y<=1$ in the Z Math Surface (object menu Add > Math Function > Z Math Surface) for the equation. I also need it to exclude the imaginary result.

(y-x+1-((y-x+1)**2 -4*y if 4*y < (y-x+1)**2 else 0 )**(1/2) ) / 2

enter image description here

I tried ((y-x+1-((y-x+1)**2 -4*y if 4*y < (y-x+1)**2 else 0 )**(1/2) ) / (2)) if x >= 0 and x <= 1 and y >= 0 and y <= 1 else 0

And also tried (((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1-(((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1)**2 -4*(y if y >= 0 and y <= 1 else 0) if 4*(y if y >= 0 and y <= 1 else 0) < ((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1)**2 else 0 )**(1/2) ) / (2))

But nothing can get me the correct result as when I plot it with python which should look like this:

enter image description here

How do I tell Z Math Surface to use a range of values within $0<=x<=1$ and $0<=y<=1$ that automatically exclude the imaginary results? Is that even possible? It probably is not possible with the math surface functions? Perhaps possible with geometry nodes?

EDIT: Also tried XYZ Math Surface which will still necessitate an if/else statement to exclude the imaginary part and will also give a squarish result:

(v-u+1-((v-u+1)**2 -4*v if 4*v < (v-u+1)**2 else 0 )**(1/2)) / 2

enter image description here

If there is a Geometry Nodes solution please feel free to post it.

Harry McKenzie
  • 10,995
  • 8
  • 23
  • 51

1 Answers1

1

Unfortunately, Z Math Surface uses the X Size and Y Size parameters to set a symmetric range of $-X Size \le X \le X Size$ and $-Y Size \le Y \le Y Size$. See below for an ugly way to make this work, but here's a simpler way using XYZ Function surfaces:

Simple solution

You can accomplish what you want using an X, Y, Z Surface, by setting $X = U$, $Y = V$, and using the U Min, U Max, V Min and V Max parameters. You also need to write the $Z$ equation using $U$ and $V$. Here's a simple example:

X,Y,Z Function surface example

Here's your equation in parametric form: $$(v-u+1-((v-u+1)**2 -4*v if 4*v < (v-u+1)**2 else 0 )**(1/2) ) / 2$$

swapping domain solution

To do this with Z Math Surface you need to change your equation. Consider using a math surface with the domain $-.5 \le X \le .5$ by setting X Size to .5. In the original equation replace $X$ with $X+.5$ everywhere. This will give you a resulting domain of $0 \le X \le 1$. The problem is that the surface will be displayed offset by .5. You can remedy this, of course, by moving the surface once it is created to compensate, but now you have fudged both the surface and the domain. (Obviously this will work just as well for $Y$.)

Marty Fouts
  • 33,070
  • 10
  • 35
  • 79
  • Hi Marty thank you for your answer! Unfortunately this will still produce a squarish result and we would still require the if/else statement to filter out the imaginary part. I updated my post with a screenshot. It looks like python is the only solution? – Harry McKenzie Aug 12 '22 at 23:22
  • @HarryMcKenzie if you specify X and Y to have the same range you'll get a squarish result no matter what you try. – Marty Fouts Aug 12 '22 at 23:42
  • yeah that's the problem XD but +1 for your answer :) – Harry McKenzie Aug 12 '22 at 23:46
  • @HarryMcKenzie The underlying problem is that the original question is too vague. OP didn't specify ranges for X and Y nor what to do with the imaginary part nor what sort of surface they wanted. – Marty Fouts Aug 12 '22 at 23:48
  • You're right. I only asked for the domain. I should have explicitly indicated that I need the imaginary parts to be excluded. I was assuming that the domain only included real numbers but alas it didn't. Sorry about that. I added the specifics in the post. I added geometry-nodes tag in case there is a geometry nodes solution. – Harry McKenzie Aug 12 '22 at 23:55
  • 1
    @HarryMcKenzie Not your problem in this question, but the OP's original problem that led to this question. Sorry I wasn't clearer. With x and y independent there's no way to solve the problem unless the OP specifies what to do with complex numbers. – Marty Fouts Aug 13 '22 at 00:05
  • by the way, Crantisz' original GN solution works you just need to restrict the domain in his grid node and rely on getting lucky with how GN handles domain errors. – Marty Fouts Aug 13 '22 at 00:07
  • yeah that's a good point that the OP did not specify what to do with this imaginary part, i just assumed that it should be excluded xd. yeah i think you're right GN hopefully can handle that. I noticed though that GN sets the imaginary parts to zero, that's why it had the same flat top result as the math surface solution. – Harry McKenzie Aug 13 '22 at 00:14
  • I extended the GN solution of Crantisz https://blender.stackexchange.com/a/271914/142292 which deletes the geometry not part of the given domain. – Harry McKenzie Aug 13 '22 at 01:40