ok, I found something here:
http://mathforum.org/library/drmath/view/55038.html
Using the equation given here, I am able to draw perpendicular lines, but not at exact distance that I want. Its all concentrated to the center.
Any suggestions? Here is my code so far (click on screen to generate fresh spirals):
Quote://
float len = random(220);
float radius1 = random(20, 130);
float radius2 = random(10, 100);
float position = random(101);
float num = random(5, 10);
float prevX = 0.0;
float prevY = 0.0;
float x = 0.0;
float y = 0.0;
//
//
float step = 1 * PI / 180.0;
float theta = 0;
int i=0;
float count = 0;
//
void setup(){
size(500, 500, P3D);
background(255);
stroke(0, 20);
}
void draw(){
count+=1;
translate(width/2, height/2);
prevX = x;
prevY = y;
x = len * cos(theta) - position * cos(len * theta / radius2);
y = len * sin(theta) - position * sin(len * theta / radius2);
theta += step;
i++;
if(prevX!=0){
stroke(0);
strokeWeight(4);
line(prevX, prevY, x,y);
// This is where i am calculating the perpendiculars
float d = 10;
float x3 = ((d)*(y-prevY))/sqrt(pow((x-prevX), 2)+pow((y-prevY),2));
float y3 = ((d)*(x-prevX))/sqrt(pow((x-prevX), 2)+pow((y-prevY),2));
//////////////////////////////////////////////
stroke(color(#ff3300));
strokeWeight(1);
line(x, y, x3, y3);
}
}
void mousePressed(){
background(255);
initL();
}
void initL(){
len = random(220);
radius1 = random(20, 130);
radius2 = random(10, 100);
position = random(101);
num = random(5, 10);
prevX = 0;
prevY = 0;
x = 0;
y = 0;
}