# Matrix-based 3D Surface Calculator

All the input boxes of the calculator can contain either numbers or expressions in a programming language
format. The parameter variables **u** and **v** can be used in those expressions, as well and all mathematical functions supported by Python,
for example sin(2 * pi * u) * cos( 2 * pi * v).

The **XYZ tab** specifies the X, Y and Z values of the initial coordinate vector. These can contain not only numbers but mathematical expressions as well.

The **U/V tab** specifies the number of steps for the U and V parameter variables. The total number of vertices in the resultant model is going to be (U+1)x(V+1).
The bigger the numbers the smoother the 3D surface is going to be, but be careful not to overload Blender with overly dense models.

The middle (matrix) section of the calculator is for entering an arbitrary number of transformation matrices. Use the "+" button to add another matrix to the end of the sequence, and "x" to remove the current matrix. A matrix tab can be dragged and dropped to move the matrix to a new location in the sequence.

At the bottom of the matrix section, there are shortcut buttons for common operations: resetting to the identity matrix, and rotations by 360° around the X, Y and Z axes using the U and V parameters.

Once the initial vector and a sequence of transformation matrices are entered, press the "Generate Python Script" button. The corresponding script will appear in the large text area at the bottom of the calculator. It can be copied directly to a Text Editor window of Blender for immediate execution. The text area can also be used to serialize the current project into a text string in JSON format (via the "Save" button) or by loading a previously saved project into the calculator (via the "Load" button.)

For a quick start, load the following matrix sequence which represents a spiral shown here:

{"x":"1", "y":"0", "z":"0","u":"64", "v":"1280", "active":0, "mapsto":0, "matrices":[{"mat":[["cos(2*pi*u)", "sin(2*pi*u)", "0", "0"], ["-sin(2*pi*u)", "cos(2*pi*u)", "0", "0"], ["0", "0", "1", "0"], ["0", "0", "0", "1"]]}, {"mat":[["1", "0", "0", "0"], ["0", "1", "0", "0"], ["0", "0", "1", "0"], ["0", "3", "0", "1"]]}, {"mat":[["1", "0", "0", "0"], ["0", "cos(20*pi*v)", "sin(20*pi*v)", "0"], ["0", "-sin(20*pi*v)", "cos(20*pi*v)", "0"], ["0", "0", "0", "1"]]}, {"mat":[["1", "0", "0", "0"], ["0", "1", "0", "0"], ["0", "0", "1", "0"], ["0", "7", "0", "1"]]}, {"mat":[["cos(2*pi*v)", "sin(2*pi*v)", "0", "0"], ["-sin(2*pi*v)", "cos(2*pi*v)", "0", "0"], ["0", "0", "1", "0"], ["0", "0", "0", "1"]]}]}

For more examples, see Tutorial 21: How to Model Parametric 3D Surfaces.