mirror of
https://github.com/DJSundog/NopSCADlib.git
synced 2024-11-23 07:13:51 -05:00
Added circle_intersect() calculation to maths.scad.
This commit is contained in:
parent
e39af154bb
commit
90e7f1a315
@ -5455,6 +5455,7 @@ Maths utilities for manipulating vectors and matrices.
|
||||
| ```argsinh(x)``` | inverse hyperbolic sine |
|
||||
| ```argtanh(x)``` | inverse hyperbolic tangent |
|
||||
| ```augment(m)``` | Augment a matrix by adding an identity matrix to the right |
|
||||
| ```circle_intersect(c1, r1, c2, r2)``` | Calculate one point where two circles in the X-Z plane intersect, clockwise around c1 |
|
||||
| ```cosh(x)``` | hyperbolic cosine |
|
||||
| ```coth(x)``` | hyperbolic cotangent |
|
||||
| ```degrees(radians)``` | Convert degrees to radians |
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 31 KiB |
@ -146,3 +146,10 @@ function invert(m) = let(n =len(m), m = solve(augment(m))) [ //! Invert a matrix
|
||||
each m[i][j]
|
||||
]
|
||||
];
|
||||
|
||||
function circle_intersect(c1, r1, c2, r2) = //! Calculate one point where two circles in the X-Z plane intersect, clockwise around c1
|
||||
let(
|
||||
v = c1 - c2, // Line between centres
|
||||
d = norm(v), // Distance between centres
|
||||
a = atan2(v.z, v.x) - acos((sqr(d) + sqr(r2) - sqr(r1)) / (2 * d * r2)) // Cosine rule to find angle from c2
|
||||
) c2 + r2 * [cos(a), 0, sin(a)]; // Point on second circle
|
||||
|
Loading…
Reference in New Issue
Block a user