{"id":117,"date":"2018-03-19T18:02:12","date_gmt":"2018-03-19T18:02:12","guid":{"rendered":"http:\/\/www.vandelle.com\/blog\/3dprinting\/?p=117"},"modified":"2018-03-19T18:02:12","modified_gmt":"2018-03-19T18:02:12","slug":"modelize-your-first-3d-shape-with-openscad-2","status":"publish","type":"post","link":"https:\/\/www.vandelle.com\/blog\/3dprinting\/2018\/03\/19\/modelize-your-first-3d-shape-with-openscad-2\/","title":{"rendered":"Modelize your first 3D shape with openSCAD #2"},"content":{"rendered":"<h2>2. Moving and changing our objects<\/h2>\n<p>&nbsp;<\/p>\n<h3>a. Translations<\/h3>\n<p>Now you know how to create shapes you maybe want to change their position in the view. It\u2019s why we\u2019ll use translate and rotate.<\/p>\n<p>To move a shape you just need to do a <strong>translate([x,y,z])<\/strong>, example :<\/p>\n<p>On the x axe :<\/p>\n<pre>translate([10,0,0]) cube(10);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-135\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/1-300x229.png\" alt=\"\" width=\"300\" height=\"229\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>On the y axe :<\/p>\n<pre>translate([0,10,0]) cube(10);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-136\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/2-300x229.png\" alt=\"\" width=\"300\" height=\"229\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>On the z axe:<\/p>\n<pre>translate([0,0,10]) cube(10);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-137\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/3-1.png\" alt=\"\" width=\"297\" height=\"266\" \/><\/p>\n<p>&nbsp;<\/p>\n<pre>$fn = 100;\n\ntranslate([20,0,0]) cube(10);\n\ntranslate([10,-10,0]) cylinder(10,5,5);;\n\ntranslate([0,0,10]) sphere(r=5);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-138\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/4-1-300x250.png\" alt=\"\" width=\"300\" height=\"250\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>b. Rotations<\/h3>\n<p>The rotation is the same thing then translation instead we work with degrees (syntax : <strong>rotate([x,y,z])<\/strong>):<\/p>\n<pre>$fn = 100;\n\ntranslate([20,0,0]) rotate([-30,0,0]) cube(10);\n\ntranslate([10,-10,0]) rotate([90,0,0]) cylinder(10,5,5);;\n\ntranslate([0,0,10]) sphere(r=5);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-139\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/5-1-300x214.png\" alt=\"\" width=\"300\" height=\"214\" \/><\/p>\n<p>The rotation is around an axe. Look at the cube we made a rotation of 30 degrees around the x axis but we go in the over direction with a <strong>-30 <\/strong>instead of just<strong> 30<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>c. Scale<\/h3>\n<p>A very interesting function when manipulating your shapes is scale(). Scaling will allow you to change the dimension of your shape by multiplication factors, example:<\/p>\n<pre>translate([20,0,0]) cube(10);\n\nscale([1,1.5,2]) cube(10);\n\nscale([1,1.5,2]) \/\/this function multiple x by 1, y by 1.5 and z by 2.<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-140\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/6-1-300x191.png\" alt=\"\" width=\"300\" height=\"191\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>d. Exercise 2<\/h3>\n<p>Try to reproduce this shape (<a href=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/modelize-your-first-3d-shape-with-openscad-correction\/\" target=\"_blank\" rel=\"noopener\">correction<\/a>)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-141\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/7-1-300x211.png\" alt=\"\" width=\"300\" height=\"211\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2. Moving and changing our objects &nbsp; a. Translations Now you know how to create shapes you maybe want to change their position in the view. It\u2019s why we\u2019ll use translate and rotate. To move a shape you just need to do a translate([x,y,z]), example : On the x axe : translate([10,0,0]) cube(10); &nbsp; On [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}