Last active
December 17, 2015 11:29
-
-
Save jaredly/5602271 to your computer and use it in GitHub Desktop.
Concentric circles for zen photon garden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculated, cached constants | |
var deltaTheta = (Math.PI * 2) / c.segments | |
, deltaRadius = (c.finalRadius - c.radius0) / c.numCircles; | |
for (var j=0; j < c.numCircles; j++) { | |
var radius1 = c.radius0 + j * deltaRadius; | |
// Create the walls | |
for (var i=0; i < segments; i+=1) { | |
var theta1 = c.theta0 + i * deltaTheta | |
, theta2 = theta1 + deltaTheta * c.segLength | |
, radius2 = radius1 + c.slant; | |
add_wall(Math.cos(theta1) * radius1 + c.x0, | |
Math.sin(theta1) * radius1 + c.y0, | |
Math.cos(theta2) * radius2 + c.x0, | |
Math.sin(theta2) * radius2 + c.y0, | |
c.transmissive, c.reflective, c.diffuse); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constants for you to play around with :) | |
var ctx = { | |
x0: ['cx', 0, -100, 100], | |
y0: ['cy', 0, -100, 100], | |
radius0: [100, 10, 200], // pixels | |
finalRadius: [200, 10, 400], | |
theta0: [0, 0, Math.PI*2], // in radians. 2*PI = full circle | |
segments: [10, 3, 50], | |
segLength: [1, 0, 10, 0.1], // 1 makes a continuous spiral | |
numCircles: [1, 1, 5, 1], | |
transmissive: [0.5, 0, 1], | |
diffuse: [0, 0, 1], | |
reflective: [0.5, 0, 1], | |
slant: [0, -10, 10] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment