3
$\begingroup$

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

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

$\endgroup$
5
  • 2
    $\begingroup$ I sincerely hope you don't have a hundred more equations you want to render and ask a question for each of them :D $\endgroup$ Aug 12, 2022 at 12:05
  • $\begingroup$ yeah. he should have gotten the idea hopefully or maybe he wants to troll us XD $\endgroup$ Aug 12, 2022 at 12:09
  • 1
    $\begingroup$ 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. $\endgroup$
    – Arsh
    Aug 13, 2022 at 4:09
  • $\begingroup$ 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. $\endgroup$ Aug 15, 2022 at 4:10
  • $\begingroup$ I just found out you can plot implicit equations using the volume cube node method in GN blender.stackexchange.com/a/300876/142292 $\endgroup$ Sep 11, 2023 at 8:54

3 Answers 3

5
$\begingroup$

You cannot plot an Implicit function in Blender. You will need another software to do that. You can plot an Implicit function using Volume Cube. 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

$\endgroup$
4
$\begingroup$

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 +/- ((x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y)**(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 x**2 - 2*x*y - 2*x + y**2 + 2*y + 1 - 4*y

def get_graph_z(x, y, real, sign = 1):
    return (y-x+1)*0.5 + (real**0.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("graph")
    m = o.data
    m.clear_geometry()
    m.from_pydata(verts, (), ())

draw_graph()

enter image description here

And then you can use the method described in How can I convert a complex point cloud to mesh to convert it to a mesh.

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

$\endgroup$
0
1
$\begingroup$

You can also use Volume Cube node:

enter image description here

enter image description here

$\endgroup$

You must log in to answer this question.

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