Creating Lab3D models: static and dynamic

Lab3D models are created from mathematical equations written in the C programming language. As such, command lines usually have to end with semicolon (;).

It is possible to create surfaces and curves using parametric equations that take parameter u if it is a curve, u and v if it is a surface and an additional parameter t (time) if the model is dynamic.

Be advised that creating advanced 3D surfaces and curves may require proficiency in vector calculus.

Take a look at the video tutorial demonstrating how to create a Lab3D Model:

1. Model types

It is necessary to choose one of the model types available:

– Curves or surfaces;
– Static or dynamic.

If you load data from an existing Lab3D file, all information from that file is loaded into the Create 3D Model screen.

1.1 Curves

Curves are one-dimensional mappings of R -> R³. In Lab3D, curves take an argument uu varying from 0 to 1 and map its values into three-dimensional coordinates.

Example: the function

Func(u) = [sin(u), cos(u), u], 0 ≤ u ≤ 2π

is a curve that draws a helix.

1.2 Surfaces

Surfaces are two-dimensional mappings of R² -> R³. In Lab3D, surfaces take two arguments uu and vv varying from 0 to 1 and map the values into three-dimensional coordinates.

Example: the function

Func(u,v) = [sin(u), cos(u), v] , 0 ≤ u ≤ 2π, 0 ≤ v ≤ 1

is the surface of a cylinder.

1.3 Dynamic models

Items 1.1 and 1.2 describe how to create static models. If the model is dynamic you can use an extra variable, t, which represents simulation time.

For example, dynamic curves are parameterized using u and the time t. Dynamic surfaces are parameterized using u, v and t.

2. Textures

Textures are elements that enrich the 3D experience. Using Lab3D, it is possible to apply textures loaded from files, text textures and no textures to 3D models. Note: the color chosen for the 3D model is blended with the texture. Choose color White to preserve the original texture colors.

2.1 No texture

If you don’t want to use textures, select the option not to use textures. You can then use the color button to specify what should be the color of the model. If you use this method it will be possible to change the model color using Lab3D environment.

2.2 Texture from file

You may load the texture from a file by selecting the Load File option. Just load a picture file. You can preview the texture in the Texture screen.

2.3 Font texture

If you want to draw text into the 3D model, select the Write Text option. You can then type the text you want to be drawn, text font and foreground/background colors.

3. Model equations

The model equations screen is where you input the parametric equations that describe the 3D models. Depending on the model chosen, you can use parameters u,v and time t to describe the 3D model. From here it is possible to preview the model in the Lab3D screen, add the model into Lab3D’s current models or save a Lab3D file.

Warning: dynamic models may be very computation intensive. I recommend using those only if really necessary.

3.1 Parameters u and v

A built-in code is included to transform uu and vv coordinates, which range from 0 to 1, into u and v coordinates that range from umin and vmin to umax and vmax. Change the min and max values to the values you want.

3.2 Coordinates

The variable Coords is a 3-component vector that transforms u, v and t, according to the model type, into the three dimensional space.

3.3 Color

You can set the color coordinates and transparency per vertex if you want to. If you don’t want to set the colors leave Color = 0, as default. You may use the parameters u, v and t, according to the model type, to set the colors.

The color values should range from 0 to 1, and the components mean:

Color.x – Red component of vertex color
Color.y – Green component of vertex color
Color.z – Blue component of vertex color
Color.w – Transparency of vertex

3.4 Normal vectors

If the normal vectors are set to 0, Lab3D automatically calculates them. However, you can manually specify the normals in terms of u, v and the time t, according to the chosen model, if you want to.

3.5 Texture coordinates

Texture coordinates are automatically generated by Lab3D.

You may change the texture coordinates if you want to. If you are using textures, either from pictures or from a text, you can specify the texture coordinates ranging from 0 to 1, representing 0 to 100% of the picture. These represent which point of the texture should be associated with the current vertex.

4. Settings

In the settings screen, it is possible to set visualization options for the 3D models. The preview button can be used to accept the changes in the settings and preview the model in the Lab3D main screen.

4.1 Model quality

The model quality is related to how many points are used to render the mathematical equations. The more points, the smoother the model. However, using too many points may slow down the system.

You can choose from one of the predefined qualities or specify your own number of points in each direction.

4.2 Render style

The render styles are used to choose what kind of model visualization should be used:

Solid – draws solid model surfaces;
Wireframe – draws the line edges of the model surfaces;
Points – draws only the vertexes of the model using points.

4.3 Advanced custom functions

Advanced custom functions can be used by programmers to create functions that will be called from the model equations. The programming structure is:

<advanced functions>

function VertexEquations (float u, float v, float t)
{  (hidden from user)

<user vertex functions>

Finalizations (hidden from user)
}

For example, if you create the advanced function Cone like:

float TwoTimes(float u)
{
return 2*u;
}

You can call

Coords.x = TwoTimes(u);

From the equation screen.

Leave a Reply

Your email address will not be published. Required fields are marked *