mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-25 05:51:41 +02:00
refactor
This commit is contained in:
@@ -1 +1 @@
|
||||
function __to_degree(radians) = (radians * 180) / PI;
|
||||
function __to_degree(radians) = radians * 57.29577951308233;
|
@@ -8,21 +8,22 @@
|
||||
*
|
||||
**/
|
||||
|
||||
use <util/degrees.scad>;
|
||||
use <util/radians.scad>;
|
||||
|
||||
function bauer_spiral(n, radius = 1, rt_dir = "CT_CLK") =
|
||||
let(
|
||||
L = sqrt(n * PI),
|
||||
toRadians = PI / 180,
|
||||
toDegrees = 180 / PI,
|
||||
clk = rt_dir == "CT_CLK" ? 1 : -1
|
||||
)
|
||||
[
|
||||
for(k = 1; k <= n; k = k + 1)
|
||||
let(
|
||||
zk = 1 - (2 * k - 1) / n,
|
||||
phik = acos(zk) * toRadians,
|
||||
phik = radians(acos(zk)),
|
||||
thetak = L * phik * clk,
|
||||
phikDegrees = toDegrees * phik,
|
||||
thetakDegrees = toDegrees * thetak,
|
||||
phikDegrees = degrees(phik),
|
||||
thetakDegrees = degrees(thetak),
|
||||
xk = sin(phikDegrees) * cos(thetakDegrees),
|
||||
yk = sin(phikDegrees) * sin(thetakDegrees)
|
||||
)
|
||||
|
@@ -8,12 +8,14 @@
|
||||
*
|
||||
**/
|
||||
|
||||
use <util/degrees.scad>;
|
||||
|
||||
function torus_knot(p, q, phi_step) =
|
||||
let(tau = PI * 2)
|
||||
[
|
||||
for(phi = 0; phi < tau; phi = phi + phi_step)
|
||||
let(
|
||||
degree = phi * 180 / PI,
|
||||
degree = degrees(phi),
|
||||
r = cos(q * degree) + 2,
|
||||
x = r * cos(p * degree),
|
||||
y = r * sin(p * degree),
|
||||
|
@@ -8,4 +8,4 @@
|
||||
*
|
||||
**/
|
||||
|
||||
function degrees(radians) = (radians * 180) / PI;
|
||||
function degrees(radians) = radians * 57.29577951308233;
|
@@ -8,4 +8,4 @@
|
||||
*
|
||||
**/
|
||||
|
||||
function radians(degrees) = (degrees * PI) / 180;
|
||||
function radians(degrees) = degrees * 0.0174532925199433;
|
Reference in New Issue
Block a user