Skip to content

Parametric DNA Double Helix Generator

source

Description

A procedurally generated model of the Deoxyribonucleic Acid (DNA) double helix. This script demonstrates the power of parametric curves and polar coordinates in CadQuery. The model represents the classical B-DNA structure, featuring two intertwining sugar-phosphate backbones connected by color-coded nitrogenous base pairs. Itโ€™s an excellent educational tool for visualizing molecular biology through the lens of algorithmic design.

Key Features

  • Dual-Helix Geometry: The backbones are generated using three-dimensional parametric splines defined by sine and cosine functions:
\[x = r \cdot \cos(\theta), \quad y = r \cdot \sin(\theta), \quad z = p \cdot \theta\]
  • Color-Coded Base Pairs: Features a visual representation of adenine, thymine, cytosine, and guanine (A-T, C-G) using distinct colors for the spheres and rungs.

  • Modular Assembly: Each segment of the strand (backbone, base, and hydrogen bond) is an independent object, allowing for easy adjustment of thickness and scale.

  • Periodic Repetition: The script can generate any number of "turns" (periods) of the helix by simply adjusting the total rotation parameter.

Dimensions (Default)

  • Helix Radius: 10 mm
  • Pitch (Height per turn): 34 mm
  • Base Pair Diameter: 2 mm
  • Sphere Radius: 3 mm