mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-10 08:44:20 +02:00
tab to space
This commit is contained in:
12
src/arc.scad
12
src/arc.scad
@@ -19,11 +19,11 @@ LINE_INWARD = 2;
|
|||||||
|
|
||||||
module arc(radius, angles, width, width_mode = LINE_CROSS, fn = 24) {
|
module arc(radius, angles, width, width_mode = LINE_CROSS, fn = 24) {
|
||||||
w_offset = width_mode == LINE_CROSS ? [width / 2, -width / 2] : (
|
w_offset = width_mode == LINE_CROSS ? [width / 2, -width / 2] : (
|
||||||
width_mode == LINE_INWARD ? [0, -width] : [width, 0]
|
width_mode == LINE_INWARD ? [0, -width] : [width, 0]
|
||||||
);
|
);
|
||||||
|
|
||||||
difference() {
|
difference() {
|
||||||
sector(radius + w_offset[0], angles, fn);
|
sector(radius + w_offset[0], angles, fn);
|
||||||
sector(radius + w_offset[1], angles, fn);
|
sector(radius + w_offset[1], angles, fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -17,14 +17,14 @@ CAP_ROUND = 2;
|
|||||||
|
|
||||||
module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_fn = 24) {
|
module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_fn = 24) {
|
||||||
$fn = round_fn;
|
$fn = round_fn;
|
||||||
half_width = 0.5 * width;
|
half_width = 0.5 * width;
|
||||||
|
|
||||||
atan_angle = atan2(p2[1] - p1[1], p2[0] - p1[0]);
|
atan_angle = atan2(p2[1] - p1[1], p2[0] - p1[0]);
|
||||||
angle = 90 - atan_angle;
|
angle = 90 - atan_angle;
|
||||||
|
|
||||||
offset_x = half_width * cos(angle);
|
offset_x = half_width * cos(angle);
|
||||||
offset_y = half_width * sin(angle);
|
offset_y = half_width * sin(angle);
|
||||||
|
|
||||||
offset1 = [-offset_x, offset_y];
|
offset1 = [-offset_x, offset_y];
|
||||||
offset2 = [offset_x, -offset_y];
|
offset2 = [offset_x, -offset_y];
|
||||||
|
|
||||||
@@ -32,27 +32,27 @@ module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_
|
|||||||
p1 + offset1, p2 + offset1,
|
p1 + offset1, p2 + offset1,
|
||||||
p2 + offset2, p1 + offset2
|
p2 + offset2, p1 + offset2
|
||||||
]);
|
]);
|
||||||
|
|
||||||
module square_end(point) {
|
module square_end(point) {
|
||||||
translate(point)
|
translate(point)
|
||||||
rotate(atan_angle)
|
rotate(atan_angle)
|
||||||
square(width, center = true);
|
square(width, center = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
module round_end(point) {
|
module round_end(point) {
|
||||||
translate(point)
|
translate(point)
|
||||||
circle(half_width, center = true);
|
circle(half_width, center = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p1Style == CAP_SQUARE) {
|
if(p1Style == CAP_SQUARE) {
|
||||||
square_end(p1);
|
square_end(p1);
|
||||||
} else if(p1Style == CAP_ROUND) {
|
} else if(p1Style == CAP_ROUND) {
|
||||||
round_end(p1);
|
round_end(p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p2Style == CAP_SQUARE) {
|
if(p2Style == CAP_SQUARE) {
|
||||||
square_end(p2);
|
square_end(p2);
|
||||||
} else if(p2Style == CAP_ROUND) {
|
} else if(p2Style == CAP_ROUND) {
|
||||||
round_end(p2);
|
round_end(p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -12,21 +12,21 @@
|
|||||||
|
|
||||||
module polyline2d(points, width, startingStyle = CAP_SQUARE, endingStyle = CAP_SQUARE, round_fn = 24) {
|
module polyline2d(points, width, startingStyle = CAP_SQUARE, endingStyle = CAP_SQUARE, round_fn = 24) {
|
||||||
module line_segment(index) {
|
module line_segment(index) {
|
||||||
styles = index == 1 ? [startingStyle, CAP_ROUND] : (
|
styles = index == 1 ? [startingStyle, CAP_ROUND] : (
|
||||||
index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [
|
index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [
|
||||||
CAP_ROUND, CAP_ROUND
|
CAP_ROUND, CAP_ROUND
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
line2d(points[index - 1], points[index], width,
|
line2d(points[index - 1], points[index], width,
|
||||||
p1Style = styles[0], p2Style = styles[1],
|
p1Style = styles[0], p2Style = styles[1],
|
||||||
round_fn = round_fn);
|
round_fn = round_fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
module polyline2d_inner(points, index) {
|
module polyline2d_inner(points, index) {
|
||||||
if(index < len(points)) {
|
if(index < len(points)) {
|
||||||
line_segment(index);
|
line_segment(index);
|
||||||
polyline2d_inner(points, index + 1);
|
polyline2d_inner(points, index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user