Coding challenge

In 3D space, a helix is created by stepping an angle $t$ and drawing points along a cylinder: $x = R\cos(t)$, $y = R\sin(t)$, $z = c \cdot t$. A double helix (like DNA) has two intertwined spirals separated by an angle of $\pi$ radians ($180^\circ$).

Using scene3d(), write a loop from $t = -50$ to $50$ that draws red spheres with sphere(x1, y1, z1, 1.2, "ff0000") along one strand, and blue spheres with sphere(x2, y2, z2, 1.2, "0000ff") along the other. Call spin(15) to watch your double helix rotate in 3D!

Type your code here:


Lua reference

See your results here: