mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 19:24:35 +02:00
refactor: use norm
This commit is contained in:
@@ -14,8 +14,9 @@ use <__comm__/__nearest_multiple_of_4.scad>;
|
|||||||
module line2d(p1, p2, width = 1, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE") {
|
module line2d(p1, p2, width = 1, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE") {
|
||||||
half_width = 0.5 * width;
|
half_width = 0.5 * width;
|
||||||
|
|
||||||
atan_angle = atan2(p2.y - p1.y, p2.x - p1.x);
|
v = p2 - p1;
|
||||||
leng = sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2));
|
atan_angle = atan2(v.y, v.x);
|
||||||
|
leng = norm(v);
|
||||||
|
|
||||||
frags = __nearest_multiple_of_4(__frags(half_width));
|
frags = __nearest_multiple_of_4(__frags(half_width));
|
||||||
|
|
||||||
|
@@ -17,13 +17,10 @@ module line3d(p1, p2, diameter = 1, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCL
|
|||||||
frags = __nearest_multiple_of_4(__frags(r));
|
frags = __nearest_multiple_of_4(__frags(r));
|
||||||
half_fa = 180 / frags;
|
half_fa = 180 / frags;
|
||||||
|
|
||||||
dx = p2.x - p1.x;
|
v = p2 - p1;
|
||||||
dy = p2.y - p1.y;
|
length = norm(v);
|
||||||
dz = p2.z - p1.z;
|
ay = 90 - atan2(v.z, norm([v.x, v.y]));
|
||||||
|
az = atan2(v.y, v.x);
|
||||||
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);
|
|
||||||
|
|
||||||
angles = [0, ay, az];
|
angles = [0, ay, az];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user