Using OpenSCAD to model 3D structures

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Conclusions

It only takes a few lines to generate complex geometric structures with OpenSCAD. Thanks to the STL transformation, other programs can also understand the results. Most of the Slicer programs can successfully implement the results for a 3D print provided the user specifies the dimensions for the length.

The 3D renderer Blender dresses up the SLT models with lighting effects and reflections and in doing so utilizes the dimensional accuracy of the models. If you are thinking of trying OpenSCAD out online without installing it, you should take a look at Openjscad [6].

Listing 3

Plotting Earthquakes

$fn=100;
$vpd=5500; // camera distance
$vpr=[88,0,300]; // camera orientation
r=1000; // Radius
// The file eq03.scad contains two arrays
// with the positions (eqlock) and the derivative
// sizes for earthquake magnitude and depth (eqspec).
include <eq03.scad>
// coordinates of some selected points
plock=[
[52, 13, 0], // Berlin
[48, 11, 0], // Munich
[35, 139, 0], // Tokyo
[21, -157, 0] // Honolulu
];
// Designation of the selected points
plockname=["Berlin", "Munich", "Tokyo", "Honolulu"];
// Output for eqlock and eqspec
for (i=[0:len(eqlock)-1]){
 translate(ku2ka(eqlock[i])) color([eqspec[i][0],1-eqspec[i][0],0]) sphere(eqspec[i][1]);
}
// Output of the selected points
for (i=[0:len(plock)-1]){
 translate(ku2ka(plock[i])) color("black") sphere(10);
 translate(ku2ka(plock[i])) color("black") text(text=plockname[i], size=30);
}
sphere(450); //draws inner sphere
grid(15); //draws grid
// transforms sphere coordinates into
function ku2ka(v)= [
 cos(v.y) * (r-v.z) * sin(90-v.x),
 sin(v.y) * (r-v.z) * sin(90-v.x),
 (r-v.z) * cos(90-v.x)];
// draws a height and width grid
module grid(d=30){
 mirrorc()
 rotate_extrude(){
 for (i=[0:d:85]){
 a= ku2ka([0,i,0]);
 translate(a) circle(5);
 };
 };
 for (i=[0:d:185])
 rotate([0,0,i])
 rotate([90,0,0])
 rotate_extrude()
 translate([r,0,0]) circle(5);
}
// Help module, for mirroring a block
module mirrorc(v=[0,0,1]){
 children();
 mirror(v) children();
};

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content