mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-19 13:01:37 +02:00
used built-in modules
This commit is contained in:
@@ -16,19 +16,13 @@ module line2d(p1, p2, width, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE") {
|
|||||||
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;
|
leng = sqrt(pow(p2[0] - p1[0], 2) + pow(p2[1] - p1[1], 2));
|
||||||
|
|
||||||
offset_x = half_width * cos(angle);
|
translate(p1)
|
||||||
offset_y = half_width * sin(angle);
|
rotate(atan_angle)
|
||||||
|
translate([0, -width / 2])
|
||||||
offset1 = [-offset_x, offset_y];
|
square([leng, width]);
|
||||||
offset2 = [offset_x, -offset_y];
|
|
||||||
|
|
||||||
polygon(points=[
|
|
||||||
p1 + offset1, p2 + offset1,
|
|
||||||
p2 + offset2, p1 + offset2
|
|
||||||
]);
|
|
||||||
|
|
||||||
frags = __frags(half_width);
|
frags = __frags(half_width);
|
||||||
|
|
||||||
remain = frags % 4;
|
remain = frags % 4;
|
||||||
|
Reference in New Issue
Block a user