Using OpenSCAD to model 3D structures
|
Visualization
OpenSCAD is also suitable for visualizing larger volumes of data. This would include things like the location for all magnitude 5 earthquakes and stronger which occurred in the previous year [4].
The graphic displays the geographical location of the earthquake, the strength expressed in relationship to the diameter of a sphere, and the depth of the earthquake focus, which appears in the arrangement underneath the coordinate grid and also by means of color (Figure 8).
The coordinates and strength of the earthquakes are found in two arrays in the eq03.scad file. The code used for the example uses the coordinates of several cities for purposes of orientation. Coordinates and names are found in the plock and plockname arrays.
The loop iterates over all elements. The number of elements is given by the len() command. The self-defined function ku2ka determines the cartesian coordinates x , y , and z from the length, width, and depth of the spherical coordinates. The function accepts one vector and returns the computed vector.
The most complex task is building the grid. OpenSCAD does not have one-dimensional lines without filling. As a result, you should construct these in the form of 3D objects from extruded slices of circles. The small black sphere in the graphic represents the city of Honolulu in Hawaii. The text is not readable in the reproduction. To the southwest, there are the Pacific and Australian plates that collide against one another. The earthquakes on the surface are represented by the color green, and the deep earthquakes can be recognized by the color red.
Search for Errors
The most important document for OpenSCAD is found in Help | Cheat_sheet . This is a complete list of commands recognized by the software [5]. Error messages that appear during script compilation appear in the console.
You will notice that a semicolon is missing when the program stumbles when switching to a succeeding command. The actual error is therefore to be found in the line that occurs before the program is interrupted. It becomes more difficult to locate semicolons that are syntactically correct but logically false. For instance, if the transformation translate([0,0,1]) is concluded with a character, this is not an error but the transformation does not produce output.
When dividing geometric objects, it can be important to maintain an overview of which portion comes from which object. Placing the pound symbol (# ) in front of the command gives you this overview. The software will show the object as half transparent.
Placing an asterisk (* ) in front blocks a command line. An exclamation mark (! ) blocks the execution of all other lines, which in effect only shows the result of the line under consideration. The echo command writes the values of variables or also results of expressions (echo(3 * 4) ) to the console.
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 6
(incl. VAT)