# Create a 3D voxel image out of an math function

• Dec 23rd 2012, 10:38 AM
host
Create a 3D voxel image out of an math function
Hey!

I have an equation F(a,b) = ( X(a,b), Y(a,b), Z(a,b) ) and i want to create a 3D voxel image out of it ( like this ). Therefore i create a new empty image and run through it. For every voxel i check if i'm inside or outside of the object that the equation F(a,b) describes. There is my problem. How can i convert the equation F(a,b) so that i can check for a point (x,y,z) if i'm inside or outside?

• Dec 23rd 2012, 12:24 PM
chiro
Re: Create a 3D voxel image out of an math function
Hey host.

Have you considered or heard about the convex hull? It is used in computational geometry for this very reason (also consider other bounding elements).

Convex Hull Algorithms
• Dec 23rd 2012, 02:13 PM
host
Re: Create a 3D voxel image out of an math function
Quote:

Originally Posted by chiro
Have you considered or heard about the convex hull?

Yes, i'm aware of the idea of the convex hull. Sorry for my bad english. I will be trying to explain better what i want to do.

I create an image of 100 pixel x 100 pixel x 100 pixel. At the beginning every pixel is empty (= 0). Now i run through the image pixel per pixel and check with the equation if i'm outside of the object or inside (here is my problem). If i'm inside i have to set the value to 1. At the end i have an image with an approximation of the object with pixels that have the value 1.

So my problem is, if i run through the image i have the coordinates x, y and z and i only have an equation F(a,b) = ( X(a,b), Y(a,b), Z(a,b) ) that describes the surface of an object. Is there any possibility to to check if i'm inside or outside of that object?
• Dec 23rd 2012, 02:21 PM
ILikeSerena
Re: Create a 3D voxel image out of an math function
Hi host! :)

Suppose instead of running through each pixel, you run through each value of (a,b) with some (small enough) step size (that can be optimized).
Set each pixel you find to 1.
Afterward, scan through each line and fill pixels whenever you pass a 1, and stop filling when you pass another 1.
• Dec 23rd 2012, 02:25 PM
chiro
Re: Create a 3D voxel image out of an math function
Consider a modified form of the Bresenham line algorithm across a surface:

Bresenham's line algorithm - Wikipedia, the free encyclopedia
• Dec 29th 2012, 01:21 AM
host
Re: Create a 3D voxel image out of an math function
Thank you guys!

Quote:

Originally Posted by ILikeSerena
Suppose instead of running through each pixel, you run through each value of (a,b) with some (small enough) step size (that can be optimized). Set each pixel you find to 1.

That works for me :).

Quote:

Originally Posted by ILikeSerena
Afterward, scan through each line and fill pixels whenever you pass a 1, and stop filling when you pass another 1.

The equation describes a concave surface. So i had to scan in -x and x direction and in -y and y direction if i'm inside of the hull.