Models

chiral_sonic_bloom.scad

Source: chiral_sonic_bloom.scad
// ---------------------------------------------------------
// THE CHIRAL SONIC BLOOM – POLYHEDRON VERSION
// ---------------------------------------------------------

/* [Path Parameters] */
path_resolution = 360; // [100:20:1000]
major_radius = 60; // [20:1:150]
minor_radius = 20; // [5:1:60]
radial_freq = 3; // [1:1:10]
height_freq = 5; // [1:1:12]
height_amp = 25; // [0:1:80]

/* [Tube Parameters] */
tube_sides = 16; // [3:1:32]
tube_base_r = 6; // [2:1:15]
tube_pulse_amp = 2; // [0:1:8]
tube_pulse_freq = 9; // [1:1:20]

/* [Twist] */
mobius_twist_turns = 1.0; // [0:0.1:5.0]

/* [View] */
show_wireframe = false;

// ---------------------------------------------------------
// MATH HELPERS
// ---------------------------------------------------------

// Parametric path position (radius + vertical modulation)
function get_pos(t, r_maj, r_min, r_f, h_a, h_f) =
  let (
    r = r_maj + r_min * sin(t * r_f),
    z = h_a * sin(t * h_f)
  ) [r * cos(t), r * sin(t), z];

// Tube radius modulation along path
function get_tube_r(t, base, amp, f) = base + amp * sin(t * f);

// Rotation matrix aligning +Z to a vector
function align_z_matrix(vt) =
  let (
    u = vt / norm(vt),
    v0 = [0, 0, 1],
    ax = cross(v0, u),
    ln = norm(ax)
  ) ln < 1e-5 ? [
      [1, 0, 0],
      [0, 1, 0],
      [0, 0, 1],
    ]
  : let (
    c = v0 * u,
    s = ln,
    C = 1 - c,
    x = ax[0] / s,
    y = ax[1] / s,
    z = ax[2] / s
  ) [
      [x * x * C + c, x * y * C - z * s, x * z * C + y * s],
      [y * x * C + z * s, y * y * C + c, y * z * C - x * s],
      [z * x * C - y * s, z * y * C + x * s, z * z * C + c],
  ];

// Apply 3×3 matrix to a point
function transform(p, m) =
  [
    p[0] * m[0][0] + p[1] * m[0][1] + p[2] * m[0][2],
    p[0] * m[1][0] + p[1] * m[1][1] + p[2] * m[1][2],
    p[0] * m[2][0] + p[1] * m[2][1] + p[2] * m[2][2],
  ];

// ---------------------------------------------------------
// POLYHEDRON GENERATOR
// ---------------------------------------------------------

module sonic_bloom_polyhedron(
  res,
  sides,
  r_maj,
  r_min,
  r_f,
  h_a,
  h_f,
  t_base,
  t_amp,
  t_f,
  twists
) {
  step = 360 / res;
  ang_per_side = 360 / sides;

  // ---- vertex rings ----
  points = [
    for (i = [0:res - 1]) let (
      t = i * step,
      pos = get_pos(t, r_maj, r_min, r_f, h_a, h_f),
      pos_n = get_pos(t + step, r_maj, r_min, r_f, h_a, h_f),
      tangent = pos_n - pos,
      mat = align_z_matrix(tangent),
      tr = get_tube_r(t, t_base, t_amp, t_f),
      twist = 360 * twists * (i / res)
    ) for (j = [0:sides - 1]) let (
      theta = j * ang_per_side + twist,
      local = [tr * cos(theta), tr * sin(theta), 0]
    ) pos + transform(local, mat),
  ];

  // ---- faces ----
  faces = [
    for (i = [0:res - 1]) for (j = [0:sides - 1]) let (
      i0 = i * sides + j,
      i1 = i * sides + (j + 1) % sides,
      i2 = ( (i + 1) % res) * sides + (j + 1) % sides,
      i3 = ( (i + 1) % res) * sides + j
    ) [i0, i1, i2, i3],
  ];

  // Lift it onto the bed: its lowest vertex on z = 0.
  // The faces above wind inward; reversed, they face out.
  translate([0, 0, -min([for (p = points) p[2]])])
    polyhedron(points=points, faces=[for (f = faces) [for (k = [len(f) - 1:-1:0]) f[k]]], convexity=10);
}

// ---------------------------------------------------------
// RENDER
// ---------------------------------------------------------

color([1, 0.55, 0.2, 0.8])
  sonic_bloom_polyhedron(
    res=path_resolution,
    sides=tube_sides,
    r_maj=major_radius,
    r_min=minor_radius,
    r_f=radial_freq,
    h_a=height_amp,
    h_f=height_freq,
    t_base=tube_base_r,
    t_amp=tube_pulse_amp,
    t_f=tube_pulse_freq,
    twists=mobius_twist_turns
  );

chiral_sonic_bloom.scad on GitHub

crystal_helix_knot.scad

Source: crystal_helix_knot.scad
// ---------------------------------------------------------
// THE CRYSTALLINE HELIX – POLYHEDRON VERSION
// ---------------------------------------------------------

/* [Path Parameters] */
path_cycles = 1; // [1:1:5] Number of full repetitions
path_resolution = 200; // [50:1:500] Vertices along the path (Higher is smoother)
overall_radius = 40; // [20:1:100] Overall radius of the knot
height_amplitude = 30; // [0:1:50] Vertical wiggle amplitude

// Knot Frequencies (A and B should be co-prime)
frequency_a = 3; // [1:1:5] X/Y Frequency
frequency_b = 5; // [1:1:5] Z Frequency

/* [Tube Parameters] */
tube_segments = 6; // [3:1:16] Sides of the cross-section (Low = more crystalline)
tube_base_radius = 8; // [1:1:15] Average tube radius
tube_pulse_amplitude = 3; // [0:1:5] Radius pulsation amount
pulse_frequency = 8; // [1:1:20] Radius pulsation frequency

/* [Twist] */
// For a perfect seam, this should be a multiple of 360
axial_twist_degrees = 360; // [0:1:1080]

/* [View] */
show_control_points = false;

// ---------------------------------------------------------
// MATH FUNCTIONS
// ---------------------------------------------------------

// Knot path position P(t)
function get_pos(t, r, h, fa, fb) =
  [
    r * cos(t * fa),
    r * sin(t * fa),
    h * cos(t * fb),
  ];

// Pulsating tube radius r(t)
function get_radius(t, base, amp, freq) =
  base + amp * sin(t * freq);

// Axis-angle rotation matrix
function rot_matrix(angle, axis) =
  let (
    c = cos(angle),
    s = sin(angle),
    C = 1 - c,
    x = axis[0],
    y = axis[1],
    z = axis[2]
  ) [
      [x * x * C + c, x * y * C - z * s, x * z * C + y * s],
      [y * x * C + z * s, y * y * C + c, y * z * C - x * s],
      [z * x * C - y * s, z * y * C + x * s, z * z * C + c],
  ];

// Transform point by 3×3 matrix
function transform(p, m) =
  [
    p[0] * m[0][0] + p[1] * m[0][1] + p[2] * m[0][2],
    p[0] * m[1][0] + p[1] * m[1][1] + p[2] * m[1][2],
    p[0] * m[2][0] + p[1] * m[2][1] + p[2] * m[2][2],
  ];

// ---------------------------------------------------------
// MESH GENERATION
// ---------------------------------------------------------

module crystalline_polyhedron(
  cycles,
  res,
  r,
  h,
  fa,
  fb,
  segs,
  r_base,
  r_amp,
  p_freq,
  twist
) {
  step = (cycles * 360) / res;

  // Vertex rings
  points = [
    for (i = [0:res - 1]) let (
      t = i * step,
      pos = get_pos(t, r, h, fa, fb),
      pos_n = get_pos(t + step, r, h, fa, fb),
      tangent = (pos_n - pos) / norm(pos_n - pos),
      up = [0, 0, 1],
      safe_up = (abs(tangent[2]) > 0.9) ? [0, 1, 0] : up,
      axis_vec = cross(safe_up, tangent),
      axis_norm = norm(axis_vec) < 1e-4 ? [1, 0, 0] : axis_vec / norm(axis_vec),
      angle_to_tan = acos(tangent[2]),
      cur_r = get_radius(t, r_base, r_amp, p_freq),
      cur_twist = (twist * i) / res,
      mat_align = rot_matrix(angle_to_tan, axis_norm)
    ) for (j = [0:segs - 1]) let (
      theta = (360 / segs) * j + cur_twist,
      circle_pt = [cur_r * cos(theta), cur_r * sin(theta), 0],
      aligned = transform(circle_pt, mat_align)
    ) pos + aligned,
  ];

  // Quad faces between rings
  faces = [
    for (i = [0:res - 1]) for (j = [0:segs - 1]) let (
      a = i * segs + j,
      b = i * segs + (j + 1) % segs,
      c = ( (i + 1) % res) * segs + (j + 1) % segs,
      d = ( (i + 1) % res) * segs + j
    ) [a, b, c, d],
  ];

  // Lift it onto the bed: its lowest vertex on z = 0.
  // The faces above wind inward; reversed, they face out.
  translate([0, 0, -min([for (p = points) p[2]])])
    polyhedron(points=points, faces=[for (f = faces) [for (k = [len(f) - 1:-1:0]) f[k]]], convexity=10);
}

// ---------------------------------------------------------
// MAIN RENDER
// ---------------------------------------------------------

color([0.3, 0.7, 1.0, 0.8]) // Translucent crystalline blue
  crystalline_polyhedron(
    cycles=path_cycles,
    res=path_resolution,
    r=overall_radius,
    h=height_amplitude,
    fa=frequency_a,
    fb=frequency_b,
    segs=tube_segments,
    r_base=tube_base_radius,
    r_amp=tube_pulse_amplitude,
    p_freq=pulse_frequency,
    twist=axial_twist_degrees
  );

crystal_helix_knot.scad on GitHub

hyper_gargoyle.scad

Source: hyper_gargoyle.scad
// ---------------------------------------------------------
// THE HYPER-GARGOYLE – POLYHEDRON VERSION
// ---------------------------------------------------------

/* [Master Parameters] */
path_resolution = 400; // [100:10:1000] Points along each path
total_height = 150; // [50:1:300] Overall height

/* [Spine (P1) Parameters – The Thunder-Marrow] */
spine_radius = 30;
spine_freq_xy = 4; // Spiral frequency (X/Y)
spine_freq_z = 6; // Height oscillation frequency (Z)
spine_tube_base = 6; // Base thickness of the spine tube
spine_pulse_freq = 10; // Spine radius pulsation frequency

/* [Ribs (P2 & P3) Parameters – The Circuit-Vines] */
rib_offset_radius = 15; // Distance from spine center
rib_wrap_freq = 3; // Wraps around the spine
rib_tube_base = 4;
rib_pulse_freq = 15;

/* [Resolution] */
tube_sides = 12; // [4:1:24] Cross-section polygon detail

// ---------------------------------------------------------
// MATH HELPERS
// ---------------------------------------------------------

// Spine path position: helical rise + vertical wobble
function get_spine_pos(t, r, h_max, f_xy, f_z) =
  [
    r * cos(t * f_xy),
    r * sin(t * f_xy),
    (h_max * t / 360) + 10 * sin(t * f_z),
  ];

// Pulsating radius (fraction of base)
function get_pulse_r(t, base, f) =
  base + base * 0.4 * sin(t * f);

// Rotation matrix aligning +Z to a target vector
function align_z_matrix(vt) =
  let (
    u = vt / norm(vt),
    v0 = [0, 0, 1],
    ax = cross(v0, u),
    ln = norm(ax)
  ) ln < 1e-5 ? [
      [1, 0, 0],
      [0, 1, 0],
      [0, 0, 1],
    ]
  : let (
    c = v0 * u,
    s = ln,
    C = 1 - c,
    x = ax[0] / s,
    y = ax[1] / s,
    z = ax[2] / s
  ) [
      [x * x * C + c, x * y * C - z * s, x * z * C + y * s],
      [y * x * C + z * s, y * y * C + c, y * z * C - x * s],
      [z * x * C - y * s, z * y * C + x * s, z * z * C + c],
  ];

// Apply 3×3 matrix to point
function transform(p, m) =
  [
    p[0] * m[0][0] + p[1] * m[0][1] + p[2] * m[0][2],
    p[0] * m[1][0] + p[1] * m[1][1] + p[2] * m[1][2],
    p[0] * m[2][0] + p[1] * m[2][1] + p[2] * m[2][2],
  ];

// ---------------------------------------------------------
// TUBE POLYHEDRON FROM A PATH
// ---------------------------------------------------------

// ---- vertices along the path ----
function tube_vertices(path_points, radii_list, sides) =
  let (count = len(path_points), ang_step = 360 / sides)
  [
    for (i = [0:count - 1]) let (
      pos = path_points[i],
      pos_next = i < count - 1 ? path_points[i + 1]
      : path_points[i] + (path_points[i] - path_points[i - 1]),
      tangent = pos_next - pos,
      mat = align_z_matrix(tangent),
      r = radii_list[i]
    ) for (j = [0:sides - 1]) let (
      theta = j * ang_step,
      local = [r * cos(theta), r * sin(theta), 0]
    ) pos + transform(local, mat),
  ];

module render_tube_from_path(path_points, radii_list, sides) {

  count = len(path_points);
  vertices = tube_vertices(path_points, radii_list, sides);

  // ---- side faces (quads between rings) ----
  faces_sides = [
    for (i = [0:count - 2]) for (j = [0:sides - 1]) let (
      curr = i * sides + j,
      next_col = i * sides + (j + 1) % sides,
      next_row = (i + 1) * sides + j,
      next_row_next = (i + 1) * sides + (j + 1) % sides
    ) [curr, next_col, next_row_next, next_row],
  ];

  // ---- end caps (fan from ring centers) ----
  start_center_pos = path_points[0];
  end_center_pos = path_points[count - 1];

  vert_count = len(vertices);

  vertices_capped = concat(
    vertices,
    [start_center_pos],
    [end_center_pos]
  );

  faces_caps = [
    // start cap
    for (j = [0:sides - 1]) let (
      idx_curr = j,
      idx_next = (j + 1) % sides,
      idx_center = vert_count
    ) [idx_center, idx_next, idx_curr],

    // end cap
    for (j = [0:sides - 1]) let (
      idx_curr = (count - 1) * sides + j,
      idx_next = (count - 1) * sides + (j + 1) % sides,
      idx_center = vert_count + 1
    ) [idx_center, idx_curr, idx_next],
  ];

  // The faces above wind inward; reversed, they face out.
  polyhedron(
    points=vertices_capped,
    faces=[for (f = concat(faces_sides, faces_caps)) [for (k = [len(f) - 1:-1:0]) f[k]]],
    convexity=10
  );
}

// ---------------------------------------------------------
// MAIN GEOMETRY
// ---------------------------------------------------------

module generate_hyper_gargoyle() {

  t_max = 360;
  step = t_max / path_resolution;

  // ---- spine data: position, frame, radius, parameter ----
  spine_data = [
    for (i = [0:path_resolution]) let (
      t = i * step,
      pos = get_spine_pos(
        t, spine_radius, total_height,
        spine_freq_xy, spine_freq_z
      ),
      pos_next = get_spine_pos(
        t + step, spine_radius, total_height,
        spine_freq_xy, spine_freq_z
      ),
      tangent = pos_next - pos,
      mat = align_z_matrix(tangent),
      r = get_pulse_r(t, spine_tube_base, spine_pulse_freq)
    ) [pos, mat, r, t],
  ];

  // ---- extract spine path and radii ----
  p1_points = [for (d = spine_data) d[0]];
  p1_radii = [for (d = spine_data) d[2]];

  // ---- ribs: offset in spine-local frame ----
  p2_data = [
    for (d = spine_data) let (
      center = d[0],
      mat = d[1],
      t = d[3],
      angle = t * rib_wrap_freq,
      local_offset = [
        rib_offset_radius * cos(angle),
        rib_offset_radius * sin(angle),
        0,
      ],
      world_offset = transform(local_offset, mat)
    ) [center + world_offset, get_pulse_r(t, rib_tube_base, rib_pulse_freq)],
  ];

  p3_data = [
    for (d = spine_data) let (
      center = d[0],
      mat = d[1],
      t = d[3],
      angle = t * rib_wrap_freq + 180,
      local_offset = [
        rib_offset_radius * cos(angle),
        rib_offset_radius * sin(angle),
        0,
      ],
      world_offset = transform(local_offset, mat)
    ) [center + world_offset, get_pulse_r(t, rib_tube_base, rib_pulse_freq)],
  ];

  p2_points = [for (d = p2_data) d[0]];
  p2_radii = [for (d = p2_data) d[1]];

  p3_points = [for (d = p3_data) d[0]];
  p3_radii = [for (d = p3_data) d[1]];

  // ---- lift onto the bed: the lowest vertex of the three tubes on z = 0 ----
  z_min = min([
    for (tube = [[p1_points, p1_radii], [p2_points, p2_radii], [p3_points, p3_radii]])
      min([for (v = tube_vertices(tube[0], tube[1], tube_sides)) v[2]]),
  ]);

  // ---- render: spine + two ribs ----
  translate([0, 0, -z_min]) {
    color("crimson")
      render_tube_from_path(p1_points, p1_radii, tube_sides);

    color("chartreuse")
      render_tube_from_path(p2_points, p2_radii, tube_sides);

    color("gold")
      render_tube_from_path(p3_points, p3_radii, tube_sides);
  }
}

// ---------------------------------------------------------
// RENDER CALL
// ---------------------------------------------------------

generate_hyper_gargoyle();

hyper_gargoyle.scad on GitHub

flame_plumes.scad

Source: flame_plumes.scad
// ---------------------------------------------------------
// FLAME PLUMES – POLYHEDRON VERSION
// ---------------------------------------------------------
// A flame as one closed surface: a lobed cross-section that swells, narrows to a point and twists
// faster towards the tip, so each lobe licks upward like a tongue of flame. Inspired by the flame
// sculpture in Jochen Kerdels' "Mastering OpenSCAD" (example 7); the method and code here are
// different.

/* [General Settings] */
total_height = 180; // [40:1:400]
// Tongues of flame round the plume
number_of_strands = 5; // [1:1:12]
// Rings from the base to the tip
slices_per_strand = 60; // [10:1:200]
// Points round each ring
ring_points = 120; // [24:6:360]

/* [Shape Geometry] */
// Base half-widths in X and Y
base_radius_x = 30;
base_radius_y = 26;
// Turns of twist from the base to the tip
rotations = 1; // [0:0.25:4]
// How deep the gaps between tongues cut in, as a fraction of the radius
lobe_depth = 0.45; // [0:0.05:0.9]
// How much the plume swells above its base before narrowing
swell = 0.6; // [0:0.05:1.5]

/* [Colors] */
flame_color = [1, 0.45, 0];

// ---------------------------------------------------------
// SURFACE
// ---------------------------------------------------------

// Envelope at height fraction v in [0, 1]: swells, then narrows to a point at the tip.
function envelope(v, swell) = pow(1 - v, 0.7) * (1 + swell * sin(180 * v));

// Twist at height fraction v, in degrees: slow at the base, quickening towards the tip.
function twist(v, turns) = 360 * turns * pow(v, 1.6);

// A point on the surface at height fraction v and angle a.
function surface_point(v, a, h, rx, ry, k, depth, swell, turns) =
  let (
    lobes = k < 2 ? 1 : 1 - depth + depth * (0.5 + 0.5 * cos(k * (a - twist(v, turns)))),
    r = envelope(v, swell) * lobes
  ) [rx * r * cos(a), ry * r * sin(a), h * v];

module flame_plumes(
  h = 180, rx = 30, ry = 26, k = 5, slices = 60, ring = 120, depth = 0.45, swell = 0.6, turns = 1
) {
  assert(h > 0 && rx > 0 && ry > 0, "flame_plumes: total_height and the base radii have to be more than 0");
  assert(depth >= 0 && depth < 1, "flame_plumes: lobe_depth has to be at least 0 and less than 1");
  assert(slices >= 2 && ring >= 3, "flame_plumes: it needs at least 2 slices and 3 ring points");

  // Rings 0 .. slices - 1 (the tip itself is a single point), then the tip, then the base centre.
  rings = [
    for (i = [0:slices - 1]) for (j = [0:ring - 1])
      surface_point(i / slices, 360 * j / ring, h, rx, ry, k, depth, swell, turns),
  ];
  tip = len(rings);
  base = tip + 1;
  points = concat(rings, [[0, 0, h], [0, 0, 0]]);

  function at(i, j) = i * ring + (j % ring);

  faces = concat(
    // sides, clockwise as seen from outside
    [for (i = [0:slices - 2]) for (j = [0:ring - 1]) [at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j + 1)]],
    // fan to the tip
    [for (j = [0:ring - 1]) [at(slices - 1, j), tip, at(slices - 1, j + 1)]],
    // flat base
    [for (j = [0:ring - 1]) [at(0, j), at(0, j + 1), base]]
  );

  polyhedron(points=points, faces=faces, convexity=10);
}

// ---------------------------------------------------------
// RENDER
// ---------------------------------------------------------

color(flame_color)
  flame_plumes(
    h=total_height,
    rx=base_radius_x,
    ry=base_radius_y,
    k=number_of_strands,
    slices=slices_per_strand,
    ring=ring_points,
    depth=lobe_depth,
    swell=swell,
    turns=rotations
  );

flame_plumes.scad on GitHub


This site uses Just the Docs, a documentation theme for Jekyll.