mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-03-14 19:19:47 +01:00
refactor: use norm
This commit is contained in:
parent
aa0c8e1cd7
commit
280332fb8f
@ -14,8 +14,9 @@ use <__comm__/__nearest_multiple_of_4.scad>;
|
||||
module line2d(p1, p2, width = 1, p1Style = "CAP_SQUARE", p2Style = "CAP_SQUARE") {
|
||||
half_width = 0.5 * width;
|
||||
|
||||
atan_angle = atan2(p2.y - p1.y, p2.x - p1.x);
|
||||
leng = sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2));
|
||||
v = p2 - p1;
|
||||
atan_angle = atan2(v.y, v.x);
|
||||
leng = norm(v);
|
||||
|
||||
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));
|
||||
half_fa = 180 / frags;
|
||||
|
||||
dx = p2.x - p1.x;
|
||||
dy = p2.y - p1.y;
|
||||
dz = p2.z - p1.z;
|
||||
|
||||
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);
|
||||
v = p2 - p1;
|
||||
length = norm(v);
|
||||
ay = 90 - atan2(v.z, norm([v.x, v.y]));
|
||||
az = atan2(v.y, v.x);
|
||||
|
||||
angles = [0, ay, az];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user