mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-17 20:11:50 +02:00
angle_between adds a ccw param
This commit is contained in:
12
src/_impl/_angle_between_impl.scad
Normal file
12
src/_impl/_angle_between_impl.scad
Normal file
@@ -0,0 +1,12 @@
|
||||
function angle_between_ccw_2d(v1, v2) =
|
||||
let(a = atan2(v1[0] * v2[1] - v1[1] * v2[0], v1 * v2))
|
||||
a >= 0 ? a : a + 360;
|
||||
|
||||
function angle_between_ccw_3d(v1, v2) =
|
||||
let(
|
||||
dot = v1 * v2,
|
||||
lenSq1 = v1[0] ^ 2 + v1[1] ^ 2 + v1[2] ^ 2,
|
||||
lenSq2 = v2[0] ^ 2 + v2[1] ^ 2 + v2[2] ^ 2,
|
||||
a = acos(dot / sqrt(lenSq1 * lenSq2))
|
||||
)
|
||||
a >= 0 ? a : a + 360;
|
@@ -8,4 +8,9 @@
|
||||
*
|
||||
**/
|
||||
|
||||
function angle_between(vt1, vt2) = acos((vt1 * vt2) / (norm(vt1) * norm(vt2)));
|
||||
use <_impl/_angle_between_impl.scad>;
|
||||
|
||||
function angle_between(vt1, vt2, ccw = false) =
|
||||
!ccw ? acos((vt1 * vt2) / (norm(vt1) * norm(vt2))) :
|
||||
len(vt1) == 2 ? angle_between_ccw_2d(vt1, vt2) :
|
||||
angle_between_ccw_3d(vt1, vt2);
|
@@ -3,4 +3,6 @@ to_do:
|
||||
- deprecate paths2sections(paths) -> rails2sections(rails)
|
||||
- deprecate path_scaling_sections(shape_pts, edge_path) -> rail_extruded_sections(shape_pts, rail)
|
||||
|
||||
- angle_between adds a ccw param.
|
||||
|
||||
- doc: sf add convexity
|
Reference in New Issue
Block a user