“OpenSCAD 调整模型大小和更多组合对象的方法”的版本间差异
第180行: | 第180行: | ||
=== 以其他方式组合对象 === | === 以其他方式组合对象 === | ||
到目前为止,当您想在模型中创建一个附加对象时,您只是在脚本中添加了另一个语句。最终的汽车模型是脚本中定义的所有对象的联合。您一直在隐式使用 union 命令,它是可用的布尔运算之一。当使用union布尔运算时,OpenSCAD 将所有对象的联合作为结果模型。在以下脚本中,隐式使用并集。 | 到目前为止,当您想在模型中创建一个附加对象时,您只是在脚本中添加了另一个语句。最终的汽车模型是脚本中定义的所有对象的联合。您一直在隐式使用 union 命令,它是可用的布尔运算之一。当使用union布尔运算时,OpenSCAD 将所有对象的联合作为结果模型。在以下脚本中,隐式使用并集。 | ||
<sample title="union_of_two_spheres_implicit.scad | |||
" desc=""> | |||
sphere(r=10); | |||
translate([10,0,0]) | |||
sphere(r=10); | |||
</sample> | |||
[[文件:Union of two spheres.jpg]] | |||
您可以通过在脚本中包含 union 命令来显式使用 union。 | |||
<sample title="union_of_two_spheres_explicit.scad | |||
" desc=""> | |||
union() { | |||
sphere(r=10); | |||
translate([12,0,0]) | |||
sphere(r=10); | |||
} | |||
</sample> | |||
[[文件:Union of two spheres.jpg]] | |||
您应该注意到 union 命令没有任何输入参数。这适用于所有布尔运算。联合应用于大括号内的所有对象。您还应该注意到大括号内的语句末尾有一个分号。相反,右大括号后没有分号。此语法类似于在应用于多个对象时使用转换。 | |||
总共有三个布尔运算。第二个是区别。差异命令从第一个对象中减去在大括号内定义的第二个对象和所有其他对象。当使用差分运算而不是联合时,前面的示例会产生以下模型。 | |||
<sample title="difference_of_two_spheres.scad | |||
" desc=""> | |||
difference() { | |||
sphere(r=10); | |||
translate([12,0,0]) | |||
sphere(r=10); | |||
} | |||
</sample> | |||
[[文件:Difference of two spheres.jpg]] | |||
进一步定义的对象(第三、第四等)也被减去。以下示例包含三个对象。 | |||
<sample title="difference_of_three_spheres.scad | |||
" desc=""> | |||
difference() { | |||
sphere(r=10); | |||
translate([12,0,0]) | |||
sphere(r=10); | |||
translate([0,-12,0]) | |||
sphere(r=10); | |||
} | |||
</sample> | |||
[[文件:Difference of three spheres.jpg]] | |||
第三个布尔运算是交集。交集操作只保留所有对象的重叠部分。当使用交集运算时,前面的示例会产生以下模型。 | |||
<sample title="intersection_of_three_spheres.scad | |||
" desc=""> | |||
intersection() { | |||
sphere(r=10); | |||
translate([12,0,0]) | |||
sphere(r=10); | |||
translate([0,-12,0]) | |||
sphere(r=10); | |||
} | |||
</sample> | |||
[[文件:Intersection of three spheres.jpg]] | |||
生成的模型是所有三个对象的公共区域。当大括号内仅定义前两个球体时,交点如下。 | |||
<sample title="intersection_of_two_spheres.scad | |||
" desc=""> | |||
intersection() { | |||
sphere(r=10); | |||
translate([12,0,0]) | |||
sphere(r=10); | |||
} | |||
</sample> | |||
[[文件:Intersection of two spheres.jpg]] | |||
尝试使用差集操作来创建新的车轮设计。为此,首先创建一个球体,然后从两侧减去球体的一部分。第一个球体的半径应等于所需的车轮半径(wheel_radius 变量)。其他两个球体的半径应等于 side_spheres_radius 变量。给定一个 hub_thickness 变量,为了使第一个球体中心的剩余材料的厚度等于 hub_thickness 的值,侧面球体应该沿 Y 轴的正负方向平移的单位数量是多少? | |||
<sample title="wheel_with_spherical_sides.scad" desc=""> | |||
$fa = 1; | |||
$fs = 0.4; | |||
wheel_radius=10; | |||
side_spheres_radius=50; | |||
hub_thickness=4; | |||
difference() { | |||
sphere(r=wheel_radius); | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
} | |||
</sample> | |||
[[文件:Wheel with spherical sides.jpg]] | |||
尝试通过减去四个垂直于车轮的圆柱体来从车轮上去除一些材料。气缸应放置在车轮半径的一半处并且等距。引入一个 cylinder_radius 和一个 cylinder_height 变量。cylinder_height 的值应该合适,以使圆柱体始终比移除它们的材料的厚度长。 | |||
<sample title="wheel_with_spherical_sides_and_holes.scad | |||
" desc=""> | |||
$fa = 1; | |||
$fs = 0.4; | |||
wheel_radius=10; | |||
side_spheres_radius=50; | |||
hub_thickness=4; | |||
cylinder_radius=2; | |||
cylinder_height=2*wheel_radius; | |||
difference() { | |||
// Wheel sphere | |||
sphere(r=wheel_radius); | |||
// Side sphere 1 | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
// Side sphere 2 | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
// Cylinder 1 | |||
translate([wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 2 | |||
translate([0,0,wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 3 | |||
translate([-wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 4 | |||
translate([0,0,-wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
} | |||
</sample> | |||
[[文件:Wheel with spherical sides and holes.jpg]] | |||
尝试在一个版本的汽车中使用上述车轮。 | |||
<sample title="car_with_wheels_with_spherical_sides_and_holes.scad | |||
" desc=""> | |||
$fa = 1; | |||
$fs = 0.4; | |||
wheel_radius = 10; | |||
base_height = 10; | |||
top_height = 14; | |||
track = 35; | |||
wheel_width = 10; | |||
body_roll = 0; | |||
wheels_turn = 0; | |||
side_spheres_radius=50; | |||
hub_thickness=4; | |||
cylinder_radius=2; | |||
cylinder_height=2*wheel_radius; | |||
rotate([body_roll,0,0]) { | |||
// Car body base | |||
cube([60,20,base_height],center=true); | |||
// Car body top | |||
translate([5,0,base_height/2+top_height/2 - 0.001]) | |||
cube([30,20,top_height],center=true); | |||
} | |||
// Front left wheel | |||
translate([-20,-track/2,0]) | |||
rotate([0,0,wheels_turn]) | |||
difference() { | |||
// Wheel sphere | |||
sphere(r=wheel_radius); | |||
// Side sphere 1 | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
// Side sphere 2 | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
// Cylinder 1 | |||
translate([wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 2 | |||
translate([0,0,wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 3 | |||
translate([-wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 4 | |||
translate([0,0,-wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
} | |||
// Front right wheel | |||
translate([-20,track/2,0]) | |||
rotate([0,0,wheels_turn]) | |||
difference() { | |||
// Wheel sphere | |||
sphere(r=wheel_radius); | |||
// Side sphere 1 | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
// Side sphere 2 | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
// Cylinder 1 | |||
translate([wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 2 | |||
translate([0,0,wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 3 | |||
translate([-wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 4 | |||
translate([0,0,-wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
} | |||
// Rear left wheel | |||
translate([20,-track/2,0]) | |||
rotate([0,0,0]) | |||
difference() { | |||
// Wheel sphere | |||
sphere(r=wheel_radius); | |||
// Side sphere 1 | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
// Side sphere 2 | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
// Cylinder 1 | |||
translate([wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 2 | |||
translate([0,0,wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 3 | |||
translate([-wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 4 | |||
translate([0,0,-wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
} | |||
// Rear right wheel | |||
translate([20,track/2,0]) | |||
rotate([0,0,0]) | |||
difference() { | |||
// Wheel sphere | |||
sphere(r=wheel_radius); | |||
// Side sphere 1 | |||
translate([0,side_spheres_radius + hub_thickness/2,0]) | |||
sphere(r=side_spheres_radius); | |||
// Side sphere 2 | |||
translate([0,- (side_spheres_radius + hub_thickness/2),0]) | |||
sphere(r=side_spheres_radius); | |||
// Cylinder 1 | |||
translate([wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 2 | |||
translate([0,0,wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 3 | |||
translate([-wheel_radius/2,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
// Cylinder 4 | |||
translate([0,0,-wheel_radius/2]) | |||
rotate([90,0,0]) | |||
cylinder(h=cylinder_height,r=cylinder_radius,center=true); | |||
} | |||
// Front axle | |||
translate([-20,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=track,r=2,center=true); | |||
// Rear axle | |||
translate([20,0,0]) | |||
rotate([90,0,0]) | |||
cylinder(h=track,r=2,center=true); | |||
</sample> | |||
[[文件:Car with wheels with spherical sides and holes.jpg]] |
2022年7月21日 (四) 22:08的版本
球体和调整大小的对象
到目前为止,您一直在使用立方体和圆柱体基元。OpenSCAD 中可用的另一个 3D 基元是球体。您可以使用以下命令创建球体。
sphere.scad
sphere(r=10);
您应该注意到,球体是以原点为中心创建的。输入参数 r 对应于球体的半径。 您想到的一个想法是用球形轮子代替圆柱形轮子。
试着把你的汽车的轮子做成球形。为此,将适当的圆柱体命令替换为球体命令。是否还需要围绕 X 轴旋转轮子?仍然需要 wheel_width 变量吗?当您修改wheels_turn 变量的值时,您的模型是否有任何明显的变化?
car_with_spherical_wheels.scad
$fa = 1;
$fs = 0.4;
wheel_radius = 8;
base_height = 8;
top_height = 10;
track = 40;
body_roll = 0;
wheels_turn = 20;
rotate([body_roll,0,0]) {
// Car body base
cube([60,20,base_height],center=true);
// Car body top
translate([5,0,base_height/2+top_height/2 - 0.001])
cube([30,20,top_height],center=true);
}
// Front left wheel
translate([-20,-track/2,0])
rotate([0,0,wheels_turn])
sphere(r=wheel_radius);
// Front right wheel
translate([-20,track/2,0])
rotate([0,0,wheels_turn])
sphere(r=wheel_radius);
// Rear left wheel
translate([20,-track/2,0])
rotate([0,0,0])
sphere(r=wheel_radius);
// Rear right wheel
translate([20,track/2,0])
rotate([0,0,0])
sphere(r=wheel_radius);
// Front axle
translate([-20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
// Rear axle
translate([20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
使用球体创建轮子的想法很好。您现在可以挤压球体,使它们具有更像轮子的形状。一种方法是使用 scale 命令。
尝试在空白模型上创建一个半径为 10 个单位的球体。使用 scale 命令仅沿 Y 轴将球体缩放 0.4 倍。
narrowed_spherical_wheel_using_scale.scad
scale([1,0.4,1])
sphere(r=10);
缩放对象的另一种方法是使用调整大小转换。缩放和调整大小之间的区别在于,使用缩放命令时,您必须沿每个轴指定所需的缩放因子,但在使用调整大小命令时,您必须指定沿每个轴的对象所需的结果尺寸。在前面的示例中,您从一个半径为 10 个单位(沿每个轴的总尺寸为 20 个单位)的球体开始,并沿 Y 轴将其缩放 0.4 倍。因此,沿 Y 轴的缩放球体的最终尺寸为 8 个单位。沿 X 和 Z 轴的尺寸保持不变(20 个单位),因为沿这些轴的比例因子等于 1。您可以使用以下调整大小命令获得相同的结果。
narrowed_spherical_wheel_using_resize.scad
resize([20,8,20])
sphere(r=10);
当您缩放/调整对象的大小并且您关心其结果尺寸时,使用调整大小命令会更方便。相反,当您更关心结果尺寸与起始尺寸的比率时,使用缩放命令会更方便。
尝试沿 Y 轴挤压汽车的球形车轮。使用 resize 命令和 wheel_width 变量来控制轮子的最终宽度。仅沿 Y 轴调整轮子的大小。
car_with_narrowed_spherical_wheels.scad
$fa = 1;
$fs = 0.4;
wheel_radius = 8;
base_height = 8;
top_height = 10;
track = 30;
wheel_width = 4;
body_roll = 0;
wheels_turn = -20;
rotate([body_roll,0,0]) {
// Car body base
cube([60,20,base_height],center=true);
// Car body top
translate([5,0,base_height/2+top_height/2 - 0.001])
cube([30,20,top_height],center=true);
}
// Front left wheel
translate([-20,-track/2,0])
rotate([0,0,wheels_turn])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Front right wheel
translate([-20,track/2,0])
rotate([0,0,wheels_turn])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Rear left wheel
translate([20,-track/2,0])
rotate([0,0,0])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Rear right wheel
translate([20,track/2,0])
rotate([0,0,0])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Front axle
translate([-20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
// Rear axle
translate([20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
新的车轮设计看起来很酷。您现在可以创建一个更适合这种新风格的身体。
尝试使用球体和调整大小/缩放命令代替立方体命令来创建与车轮样式相匹配的主体。
car_with_narrowed_spherical_wheels.scad
$fa = 1;
$fs = 0.4;
wheel_radius = 8;
base_height = 8;
top_height = 10;
track = 28;
wheel_width = 4;
body_roll = 0;
wheels_turn = -20;
rotate([body_roll,0,0]) {
// Car body base
resize([90,20,12])
sphere(r=10);
// Car body top
translate([10,0,5])
resize([50,15,15])
sphere(r=10);
}
// Front left wheel
translate([-20,-track/2,0])
rotate([0,0,wheels_turn])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Front right wheel
translate([-20,track/2,0])
rotate([0,0,wheels_turn])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Rear left wheel
translate([20,-track/2,0])
rotate([0,0,0])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Rear right wheel
translate([20,track/2,0])
rotate([0,0,0])
resize([2*wheel_radius,wheel_width,2*wheel_radius])
sphere(r=wheel_radius);
// Front axle
translate([-20,0,0])rotate([90,0,0])
cylinder(h=track,r=2,center=true);
// Rear axle
translate([20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
以其他方式组合对象
到目前为止,当您想在模型中创建一个附加对象时,您只是在脚本中添加了另一个语句。最终的汽车模型是脚本中定义的所有对象的联合。您一直在隐式使用 union 命令,它是可用的布尔运算之一。当使用union布尔运算时,OpenSCAD 将所有对象的联合作为结果模型。在以下脚本中,隐式使用并集。
union_of_two_spheres_implicit.scad
sphere(r=10);
translate([10,0,0])
sphere(r=10);
您可以通过在脚本中包含 union 命令来显式使用 union。
union_of_two_spheres_explicit.scad
union() {
sphere(r=10);
translate([12,0,0])
sphere(r=10);
}
您应该注意到 union 命令没有任何输入参数。这适用于所有布尔运算。联合应用于大括号内的所有对象。您还应该注意到大括号内的语句末尾有一个分号。相反,右大括号后没有分号。此语法类似于在应用于多个对象时使用转换。
总共有三个布尔运算。第二个是区别。差异命令从第一个对象中减去在大括号内定义的第二个对象和所有其他对象。当使用差分运算而不是联合时,前面的示例会产生以下模型。
difference_of_two_spheres.scad
difference() {
sphere(r=10);
translate([12,0,0])
sphere(r=10);
}
进一步定义的对象(第三、第四等)也被减去。以下示例包含三个对象。
difference_of_three_spheres.scad
difference() {
sphere(r=10);
translate([12,0,0])
sphere(r=10);
translate([0,-12,0])
sphere(r=10);
}
第三个布尔运算是交集。交集操作只保留所有对象的重叠部分。当使用交集运算时,前面的示例会产生以下模型。
intersection_of_three_spheres.scad
intersection() {
sphere(r=10);
translate([12,0,0])
sphere(r=10);
translate([0,-12,0])
sphere(r=10);
}
生成的模型是所有三个对象的公共区域。当大括号内仅定义前两个球体时,交点如下。
intersection_of_two_spheres.scad
intersection() {
sphere(r=10);
translate([12,0,0])
sphere(r=10);
}
尝试使用差集操作来创建新的车轮设计。为此,首先创建一个球体,然后从两侧减去球体的一部分。第一个球体的半径应等于所需的车轮半径(wheel_radius 变量)。其他两个球体的半径应等于 side_spheres_radius 变量。给定一个 hub_thickness 变量,为了使第一个球体中心的剩余材料的厚度等于 hub_thickness 的值,侧面球体应该沿 Y 轴的正负方向平移的单位数量是多少?
wheel_with_spherical_sides.scad
$fa = 1;
$fs = 0.4;
wheel_radius=10;
side_spheres_radius=50;
hub_thickness=4;
difference() {
sphere(r=wheel_radius);
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
}
尝试通过减去四个垂直于车轮的圆柱体来从车轮上去除一些材料。气缸应放置在车轮半径的一半处并且等距。引入一个 cylinder_radius 和一个 cylinder_height 变量。cylinder_height 的值应该合适,以使圆柱体始终比移除它们的材料的厚度长。
wheel_with_spherical_sides_and_holes.scad
$fa = 1;
$fs = 0.4;
wheel_radius=10;
side_spheres_radius=50;
hub_thickness=4;
cylinder_radius=2;
cylinder_height=2*wheel_radius;
difference() {
// Wheel sphere
sphere(r=wheel_radius);
// Side sphere 1
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
// Side sphere 2
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
// Cylinder 1
translate([wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 2
translate([0,0,wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 3
translate([-wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 4
translate([0,0,-wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
}
car_with_wheels_with_spherical_sides_and_holes.scad
$fa = 1;
$fs = 0.4;
wheel_radius = 10;
base_height = 10;
top_height = 14;
track = 35;
wheel_width = 10;
body_roll = 0;
wheels_turn = 0;
side_spheres_radius=50;
hub_thickness=4;
cylinder_radius=2;
cylinder_height=2*wheel_radius;
rotate([body_roll,0,0]) {
// Car body base
cube([60,20,base_height],center=true);
// Car body top
translate([5,0,base_height/2+top_height/2 - 0.001])
cube([30,20,top_height],center=true);
}
// Front left wheel
translate([-20,-track/2,0])
rotate([0,0,wheels_turn])
difference() {
// Wheel sphere
sphere(r=wheel_radius);
// Side sphere 1
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
// Side sphere 2
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
// Cylinder 1
translate([wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 2
translate([0,0,wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 3
translate([-wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 4
translate([0,0,-wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
}
// Front right wheel
translate([-20,track/2,0])
rotate([0,0,wheels_turn])
difference() {
// Wheel sphere
sphere(r=wheel_radius);
// Side sphere 1
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
// Side sphere 2
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
// Cylinder 1
translate([wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 2
translate([0,0,wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 3
translate([-wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 4
translate([0,0,-wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
}
// Rear left wheel
translate([20,-track/2,0])
rotate([0,0,0])
difference() {
// Wheel sphere
sphere(r=wheel_radius);
// Side sphere 1
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
// Side sphere 2
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
// Cylinder 1
translate([wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 2
translate([0,0,wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 3
translate([-wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 4
translate([0,0,-wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
}
// Rear right wheel
translate([20,track/2,0])
rotate([0,0,0])
difference() {
// Wheel sphere
sphere(r=wheel_radius);
// Side sphere 1
translate([0,side_spheres_radius + hub_thickness/2,0])
sphere(r=side_spheres_radius);
// Side sphere 2
translate([0,- (side_spheres_radius + hub_thickness/2),0])
sphere(r=side_spheres_radius);
// Cylinder 1
translate([wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 2
translate([0,0,wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 3
translate([-wheel_radius/2,0,0])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
// Cylinder 4
translate([0,0,-wheel_radius/2])
rotate([90,0,0])
cylinder(h=cylinder_height,r=cylinder_radius,center=true);
}
// Front axle
translate([-20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);
// Rear axle
translate([20,0,0])
rotate([90,0,0])
cylinder(h=track,r=2,center=true);