Equations for 3D objects

632 Views Asked by At

How can I generate equations for 3D objects beyond the basics like spheres, cubes and pyramids? For example, how about a diamond?

1

There are 1 best solutions below

0
On BEST ANSWER

One common way to represent 3D shapes is by using implicit equations. The idea is to fabricate a real-valued function $f:\mathbb R^3 \to \mathbb R$, and then the 3D object is the set $\{(x,y,z) \in \mathbb R^3 : f(x,y,z) \le 0 \}$.

Some examples:

$f(x,y,z) = x^2 + y^2 +z^2 - r^2$ gives a sphere of radius $r$.

$f(x,y,z) = x^2 + y^2 - r^2$ gives a cylinder of radius $r$.

$f(x,y,z) = x^2 + 4y^2 +9z^2 - 1$ gives an ellipsoid.

$f(x,y,z) = \max \{ |x|-1, |y|-1, |z|-1 \}$ gives a cube.

$f(x,y,z) = \max \{ |y+z|-1, |z+x|-1, |x+y|-1 \}$ gives a diamond shape.

In general, use of “max”, as in the last two examples, gives you the intersection of simpler shapes.

This page tells you about implicit surfaces, described by equations of the form $f=0$. If you just replace the $=0$ by $\le 0$, you generally get a representation of a solid object enclosed by the surface, as I described above.