I have a tricky one for all of you. I am attempting to draw in 3 dimensions using Processing and have run in to a snag. I want to draw a cylinder that arcs along a given innerRadius. I eventually want to be able to rotate it or start it at a different point in the arc, but I will be able to figure that out once I can draw the arc. My code for the arc:
void drawCurvedVessel(int sides, float r, float l, float x, float y, float z, float innerRadius, float degrees)
{
float angle = 360 / sides;
// draw top shape
float start = innerRadius*degrees;
translate(x,y,z);
for (int n = 0; n < l; n++){
float theta0 = n/innerRadius;
float theta1 = (n+1)/innerRadius;
float dx0 = innerRadius*cos(theta0);
float dy0 = innerRadius*sin(theta0);
float dx1 = innerRadius*cos(theta1);
float dy1 = innerRadius*sin(theta1);
beginShape(TRIANGLE_STRIP);
for (int i = 0; i < sides + 3; i++) {
x = cos( radians( i * angle ) ) * r;
y = sin( radians( i * angle ) ) * r;
float vertexZ1 = sin(theta1)*(innerRadius+sqrt((x+dx1)*(x+dx1)+y*y));
vertex( x+dx1, y, vertexZ1);
float vertexZ0 = sin(theta0)*(innerRadius+sqrt((x+dx0)*(x+dx0)+y*y));
vertex( x+dx0, y, vertexZ0);
}
endShape(TRIANGLE_STRIP);
}
translate(-x,-y,-z);
}
renders fairly well, except that the arc gets skewed along one side. Would you be able to help me draw an arc that is perfectly circular throughout?
EDIT: I have updated my code. It's working better, but it is not performing a full circle. Instead, it looks pinched at top and bottom like this: https://drive.google.com/file/d/0B7A0w7ZdcEuQUmIzQkFlYzBBUkk/view?usp=sharing