나는 여러분 모두를 위해 까다로운 것을 가지고 있습니다. 나는 Processing을 사용하여 3 차원을 그리려하고 있는데 걸려 넘어졌다. 주어진 innerRadius를 따라 호가있는 원통을 그립니다. 나는 결국 아크를 회전 시키거나 아크의 다른 지점에서 시작할 수 있기를 원하지만 일단 아크를 그릴 수 있다면 그것을 이해할 수있을 것입니다. 아크에 대한 내 코드 :3D 아치형 실린더 처리
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);
}
은 아크가 한면을 따라 비뚤어지는 점을 제외하면 상당히 잘 표현됩니다. 내내 완벽하게 원형 인 호를 그릴 수있게 도와 주시겠습니까?
편집 : 코드를 업데이트했습니다. 더 잘 작동하지만 전체 원형을 수행하지는 않습니다. OP에 의해 발견 https://drive.google.com/file/d/0B7A0w7ZdcEuQUmIzQkFlYzBBUkk/view?usp=sharing
원하는 경우이 질문에 대한 답변으로 솔루션을 게시 할 수 있습니다. http://stackoverflow.com/help/self-answer – kevinsa5
제목 및 질문에서 "해결 됨"을 제거하고 적절한 답으로 게시하십시오. – usr2564301