mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-02 03:02:34 +02:00
move file
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* line3d.scad
|
||||
*
|
||||
* Creates a 3D line from two points.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-line3d.html
|
||||
*
|
||||
**/
|
||||
|
||||
CAP_BUTT = 0;
|
||||
CAP_CIRCLE = 1;
|
||||
CAP_SPHERE = 2;
|
||||
|
||||
module line3d(p1, p2, thickness, p1Style = CAP_CIRCLE, p2Style = CAP_CIRCLE, fn = 24) {
|
||||
$fn = fn;
|
||||
|
||||
r = thickness / 2;
|
||||
|
||||
dx = p2[0] - p1[0];
|
||||
dy = p2[1] - p1[1];
|
||||
dz = p2[2] - p1[2];
|
||||
|
||||
|
||||
length = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
|
||||
|
||||
ay = 90 - atan2(dz, sqrt(pow(dx, 2) + pow(dy, 2)));
|
||||
az = atan2(dy, dx);
|
||||
|
||||
module cap_butt() {
|
||||
translate(p1)
|
||||
rotate([0, ay, az])
|
||||
linear_extrude(length)
|
||||
circle(r);
|
||||
}
|
||||
|
||||
module capCube(p) {
|
||||
w = r / 1.414;
|
||||
translate(p)
|
||||
rotate([0, ay, az])
|
||||
translate([0, 0, -w])
|
||||
linear_extrude(w * 2)
|
||||
circle(r);
|
||||
}
|
||||
|
||||
module capSphere(p) {
|
||||
translate(p)
|
||||
rotate([0, ay, az])
|
||||
sphere(r * 1.0087);
|
||||
}
|
||||
|
||||
module cap(p, style) {
|
||||
if(style == CAP_CIRCLE) {
|
||||
capCube(p);
|
||||
} else if(style == CAP_SPHERE) {
|
||||
if(fn > 4) {
|
||||
capSphere(p);
|
||||
} else {
|
||||
capCube(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cap_butt();
|
||||
cap(p1, p1Style);
|
||||
cap(p2, p2Style);
|
||||
}
|
Reference in New Issue
Block a user