How to make a double helix

From Goodblox Wiki
Jump to navigationJump to search

Introduction

The DNA molecule can be represented by a double helix. This tutorial is to show how to create the well-known double helix that is the DNA molecule. This tutorial will require some knowledge of trigonometry and Vectors.

File:Doublehelix.jpg
[1]

What are we going to do?

We need 2 helixes that don't cross each other's paths. In order to do this, we need a way to define the X, Y and Z coordinates for every brick going up the helix.

The double helix is a lot like a spiral staircase. Think about what you do while you walk on a spiral staircase. What do you do?

You don't do anything fancy in the "Y" (or "up and down" dimension) other than go 'up' or 'down' -- you steadily go up or down the stairs.

The "X" and "Z" dimensions are a little different. You go around and around in circles. You take a step, but you have to turn a little bit to the left (or right, depending on how your stairs go). You take another step, but you have to turn a little bit to the left again. (Put your hand on the handrail and notice that it's a nice curve that curves in one direction or the other. If you look at the handrail from above, it would look like a circle.)

Knowing this, we're going to create a circle (requiring both the math.sin(i) for one value and math.cos(i) for another value) and putting in (i) for the value of y:

p.Position=Vector3.new(100*math.cos(i), 75*i, 100*math.sin(i))

These values are multiplied, so that the bricks don't ball up on top of each other.

To create a helix going in the other direction, simply make the first value negative:

p.Position=Vector3.new(-100*math.cos(i), 75*i, 100*math.sin(i))

Setup

  • You will need to have GoodBlox Studio open.
  • Insert > Object > Script
  • Paste the following completed script and run:
local i = 0
for i = 0, 50, .1 do

	local p = Instance.new("Part")
	p.Parent = game.Workspace
	p.Name = "Brick"
	p.Size = Vector3.new(5,5,5)
	p.Anchored = true
	p.Position=Vector3.new(100*math.cos(i), 75*i, 100*math.sin(i))
	local p = Instance.new("Part")
	p.Parent = game.Workspace
	p.Name = "Brick"
	p.Size = Vector3.new(5,5,5)
	p.Anchored = true
	p.Position=Vector3.new(-100*math.sin(i), 75*i, 100*math.cos(i))
	wait()
	end