3

Is it possible to render the following equation in Blender to make a 3d visual?

$$z^2 + (x-y-1)(z) + y = 0$$

ManaTree
  • 84
  • 1
  • 10
Arsh
  • 91
  • 1
  • 1
    I sincerely hope you don't have a hundred more equations you want to render and ask a question for each of them :D – Gordon Brinkmann Aug 12 '22 at 12:05
  • yeah. he should have gotten the idea hopefully or maybe he wants to troll us XD – Harry McKenzie Aug 12 '22 at 12:09
  • Yeah no it's because I'm new to blender and I wanted to use the software to create a visual for a project. I tried plotting the explicit function and it worked but I wanted to create a visual of better quality, and so I thought an implicit equation may be better. – Arsh Aug 13 '22 at 04:09
  • Unfortunately blender does not support implicit functions, only explicit, but the resulting graph is the same depending on domain. But in your case the equation is not implicit because there is a way to make it explicit as shown in the answer. Implicit means if there is no way to find an explicit form. Also you can edit the resolution or specify a domain to get the specific portion of the graph u want. What's the math domain u need? It is missing in your question. – Harry McKenzie Aug 15 '22 at 04:10
  • I just found out you can plot implicit equations using the volume cube node method in GN https://blender.stackexchange.com/a/300876/142292 – Harry McKenzie Sep 11 '23 at 08:54

2 Answers2

4

The equation $z^2 + (x-y-1)(z) + y = 0$ has the form of a Quadratic Equation so you can derive an explicit equation in the form $z=z(x,y)$

$$Az^2+Bz+C=0$$ where: $$A=1$$ $$B=(x-y-1)$$ $$C=y$$


and $z$ can be explicitly defined as: $$z=\frac{-B\pm\sqrt{B^2-4AC}}{2A}$$ substituting we get: $$z = \frac{-(x−y−1)\pm \sqrt{\left(x−y−1\right)^{2} - 4(1)(y)}}{2(1)}$$

$$z = \frac{1}{2}(y-x+1)\pm \frac{1}{2}\sqrt{x^2 - 2xy - 2x + y^2 + 2y + 1 - 4y}$$

There are two (2) solutions:

z = (y-x+1)*0.5 + ((x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y)**(0.5))*0.5
z = (y-x+1)*0.5 - ((x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y)**(0.5))*0.5

Take note that we have an imaginary component, where, $x^2 - 2xy - 2x + y^2 + 2y + 1$ has to be greater than $4y$ or else we have a negative value in the square root function ($\sqrt{value}=value^{0.5}$) which would result to an imaginary number and cannot be visualized so we have to add a check to ignore these points. We can easily plot that in python without any problems:

import bpy

def get_object(name): objects = bpy.context.scene.objects if name in objects: return objects[name] m = bpy.data.meshes.new(name + "-mesh") o = bpy.data.objects.new(name, m) #o.modifiers.new(name, 'SKIN') bpy.context.collection.objects.link(o) return o

==================================================================================================

Equation:

Descritpion: plot z = (y-x+1)0.5 +/- ((x2 - 2xy - 2x + y2 + 2y + 1 - 4y)(0.5))*0.5

==================================================================================================

def get_range(start, end, step = 2): return [x * 0.1 for x in range(start * 10, end * 10, step)]

def get_graph_z_real(x, y): return x2 - 2xy - 2*x + y2 + 2y + 1 - 4y

def get_graph_z(x, y, real, sign = 1): return (y-x+1)0.5 + (real0.5)0.5 * sign

def create_verts(verts, sign): for py in get_range(-5, 5, 2): for px in get_range(-5, 5, 2): real = get_graph_z_real(px, py) if real < 0: continue pz = get_graph_z(px, py, real, sign) verts.append([px, py, pz])

def draw_graph(): verts = []

create_verts(verts, 1)
create_verts(verts, -1)

o = get_object(&quot;graph&quot;)
m = o.data
m.clear_geometry()
m.from_pydata(verts, (), ())

draw_graph()

enter image description here

We can also use the Z Math Surface but unfortunately there we have to add an if/else check and evaluate the square root part to zero or some other value for the imaginary component which will add an additional unwanted region in the 3d surface:

z = (y-x+1)*0.5 + ((x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y if x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 > 4*y else 0)**(0.5))*0.5
z = (y-x+1)*0.5 - ((x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y if x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 > 4*y else 0)**(0.5))*0.5

First make sure to have Extra Objects addon enabled in menu Edit > Preferences > Add-ons:

enter image description here

Then add the surface function under object menu Add > Math Function > Z Math Surface to plot the 2 solutions.

enter image description here

If I didn't make any mistake in my calculation then the graph should look like this. Notice that the imaginary part is plotted with the square root part evaluated to zero. Anyway you get the idea :)

enter image description here

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

You cannot plot an Implicit function in Blender. You will need another software to do that. However, your equation is not implicit because there is a way to convert it into an Explicit function. Implicit means that there is no way to convert it into explicit form. Here's a solution using Geometry Nodes that shows the graph for your original equation $z^2+(x−y−1)(z)+y=0$ using an explicit function that was derived from that original equation in my solution in the other answer:

$$z = \frac{1}{2}(y-x+1)\pm \frac{1}{2}\sqrt{\left(x−y−1\right)^{2} - 4y}$$

enter image description here

Take note that the jagged edges between the upper and lower graph are the exact representation of the boundary between real and imaginary (complex) numbers.

enter image description here

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