1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-09-26 06:19:12 +02:00
This commit is contained in:
Justin Lin
2022-03-06 16:24:37 +08:00
parent dff52fd168
commit 5b37c7ad86
5 changed files with 12 additions and 9 deletions

View File

@@ -1 +1 @@
function __to_degree(radians) = (radians * 180) / PI; function __to_degree(radians) = radians * 57.29577951308233;

View File

@@ -8,21 +8,22 @@
* *
**/ **/
use <util/degrees.scad>;
use <util/radians.scad>;
function bauer_spiral(n, radius = 1, rt_dir = "CT_CLK") = function bauer_spiral(n, radius = 1, rt_dir = "CT_CLK") =
let( let(
L = sqrt(n * PI), L = sqrt(n * PI),
toRadians = PI / 180,
toDegrees = 180 / PI,
clk = rt_dir == "CT_CLK" ? 1 : -1 clk = rt_dir == "CT_CLK" ? 1 : -1
) )
[ [
for(k = 1; k <= n; k = k + 1) for(k = 1; k <= n; k = k + 1)
let( let(
zk = 1 - (2 * k - 1) / n, zk = 1 - (2 * k - 1) / n,
phik = acos(zk) * toRadians, phik = radians(acos(zk)),
thetak = L * phik * clk, thetak = L * phik * clk,
phikDegrees = toDegrees * phik, phikDegrees = degrees(phik),
thetakDegrees = toDegrees * thetak, thetakDegrees = degrees(thetak),
xk = sin(phikDegrees) * cos(thetakDegrees), xk = sin(phikDegrees) * cos(thetakDegrees),
yk = sin(phikDegrees) * sin(thetakDegrees) yk = sin(phikDegrees) * sin(thetakDegrees)
) )

View File

@@ -8,12 +8,14 @@
* *
**/ **/
use <util/degrees.scad>;
function torus_knot(p, q, phi_step) = function torus_knot(p, q, phi_step) =
let(tau = PI * 2) let(tau = PI * 2)
[ [
for(phi = 0; phi < tau; phi = phi + phi_step) for(phi = 0; phi < tau; phi = phi + phi_step)
let( let(
degree = phi * 180 / PI, degree = degrees(phi),
r = cos(q * degree) + 2, r = cos(q * degree) + 2,
x = r * cos(p * degree), x = r * cos(p * degree),
y = r * sin(p * degree), y = r * sin(p * degree),

View File

@@ -8,4 +8,4 @@
* *
**/ **/
function degrees(radians) = (radians * 180) / PI; function degrees(radians) = radians * 57.29577951308233;

View File

@@ -8,4 +8,4 @@
* *
**/ **/
function radians(degrees) = (degrees * PI) / 180; function radians(degrees) = degrees * 0.0174532925199433;