# 3D Theory - Equations Model

Shapes could be defined by an inequality, for example simple shapes could be defined as follows:

#### Sphere

boolean isInside(float x, float y, float z) {return (r*r < x*x+y*y+z*z);}

#### Cube

Boolean isInside(float x, float y, float z) {return ((x<left) & (x>right) & (y<top) & (y>bottom) & (z<front) & (z>back));}

#### Other shapes

Other shapes could be made by combining these simple shapes using Boolean operations, for example a Boolean 'or' will create a new shape with an outline covering both shapes. A Boolean 'and' will create a shape with an outline which is the intersection of both shapes. An 'not and' would allow a 'bite' to be taken out of an object in the shape of the other object.

#### Movement

You could offset or move the object with the following type of method: (see Using this to model physics)

Boolean isInside(float x, float y, float z) {return shapeToBeMoved.isInside(x+xOffset, y+yOffset, z+zOffset);}

#### Uses of this method

• mataballs
• combining objects using Boolean operations