How I can rotate the cylinders from the same angle?

edited September 2015 in Questions about Code

/* to convert degrees to radians not start me all from the angle 0. How I can I can put them to begin with the same angle?

I tried with the map function, but I feel the same. */

float p=0; // angle 1 float d=180; // ange 2 float w=180; // angle 3 float topRadius=10; float bottomRadius=10; float tall=100; float sides=100; float cpx, cpy,angle = 0,angle1,angle2; int e; float rx = 0; float ry =0; int gridSize=40; float angulo=0; void setup() { size(1080, 660, P3D); } void draw() { background(0); fill(255, 255, 255);

lights(); translate(width / 2, height / 2,0);

fill(255,0,0); sphere(15);

 noStroke();

fill(255, 255, 255); translate(0, 0, 0); angle = radians(p) ; beginShape(QUAD_STRIP); for (int i = 0; i < sides + 1; ++i) { vertex(topRadiuscos(angle), 0, topRadiussin(angle)); vertex(bottomRadiuscos(angle), tall0.8,bottomRadiussin(angle)); angle += TWO_PI / sides; rotateX(angle); } endShape(); translate(0,tall0.8,0); fill(255,0,0); sphere(15); fill(255, 255, 255); angle1 = radians(d); beginShape(QUAD_STRIP); for (int i = 0; i < sides + 1; ++i) {
vertex(topRadiuscos(angle1), 0, topRadiussin(angle1)); vertex(bottomRadiuscos(angle1), tall0.6,bottomRadius*sin(angle1)); angle1 += TWO_PI / sides; rotateX(angle1); } endShape();

translate(0,tall0.6,0); fill(255,0,0); sphere(13); fill(255, 255, 255); angle2 = radians(w); beginShape(QUAD_STRIP); for (int i = 0; i < sides + 1; ++i) {
vertex(topRadius
cos(angle2), 0, topRadiussin(angle2)); vertex(bottomRadiuscos(angle2), tall0.5,bottomRadiussin(angle2)); angle2 += TWO_PI / sides; rotateX(angle2); } endShape(); translate(0,tall*0.5,0); fill(255,0,0); sphere(10); println(angle, angle1, angle2); }

Answers

Sign In or Register to comment.