从 2D 到 3D 绘图
From 2D to 3D drawing
我正在尝试绘制 3D 绘图,但我得到的只是 2D 绘图,正如您将在下面的代码中看到的那样,我正在尝试以 3D 绘制具有深度的线条,但是如果不使用盒子或根本不会移动的 3D 图形,我无法找到一种方法来做到这一点。
到目前为止,这是我的代码:
import peasy.*;
static final int Lin =100;
//Loop Vintage
float t;
int x,y,z,a,b,c;
//Camera 3D
PeasyCam cam;
void setup ()
{
background(20);
size(800,600, P3D);
//Distance of Camera
cam = new PeasyCam(this, 1000);
}
void draw()
{
background(0);
stroke(255);
strokeWeight(1);
//Loop Vintage
Floop();
}
void Floop()
{ pushMatrix();
translate(CENTER,CENTER,CENTER);
rotate(0);
for(x=0;x<Lin; x++)
line(x1(t+x),y1(t+x),x2(t+x),y2(t+x));
popMatrix();
t++;
}
//Loop Vintage
float x1(float t)
{
return sin(t/10) * 100 + sin(t/5) * 20;
}
float y1(float t)
{
return cos(t/10) * 100;
}
float x2(float t)
{
return sin(t/10) * 200 + sin(t) * 2;
}
float y2(float t)
{
return cos(t/20) * 200 + sin(t/12) * 20;
}
如您所见,您需要 peasyCam 才能看到任何改进。这段代码绘制了一个 "hyperboloid of one sheet" 之类的图形,虽然不是那么完美,但却是我发现的最接近的几何形式。我正在尝试以 3D 方式绘制它(或重新绘制线条),如果您有任何可以帮助我的想法,将不胜感激,
谢谢
我想我明白你的问题是什么,你想要它画出夸张的线条,但又想要它以 3D 形式完成。
尝试将 line
切换为 triangle
(这将需要 2 个额外参数),或 sphere
(这将需要半径。
这应该很有希望。
我正在尝试绘制 3D 绘图,但我得到的只是 2D 绘图,正如您将在下面的代码中看到的那样,我正在尝试以 3D 绘制具有深度的线条,但是如果不使用盒子或根本不会移动的 3D 图形,我无法找到一种方法来做到这一点。 到目前为止,这是我的代码:
import peasy.*;
static final int Lin =100;
//Loop Vintage
float t;
int x,y,z,a,b,c;
//Camera 3D
PeasyCam cam;
void setup ()
{
background(20);
size(800,600, P3D);
//Distance of Camera
cam = new PeasyCam(this, 1000);
}
void draw()
{
background(0);
stroke(255);
strokeWeight(1);
//Loop Vintage
Floop();
}
void Floop()
{ pushMatrix();
translate(CENTER,CENTER,CENTER);
rotate(0);
for(x=0;x<Lin; x++)
line(x1(t+x),y1(t+x),x2(t+x),y2(t+x));
popMatrix();
t++;
}
//Loop Vintage
float x1(float t)
{
return sin(t/10) * 100 + sin(t/5) * 20;
}
float y1(float t)
{
return cos(t/10) * 100;
}
float x2(float t)
{
return sin(t/10) * 200 + sin(t) * 2;
}
float y2(float t)
{
return cos(t/20) * 200 + sin(t/12) * 20;
}
如您所见,您需要 peasyCam 才能看到任何改进。这段代码绘制了一个 "hyperboloid of one sheet" 之类的图形,虽然不是那么完美,但却是我发现的最接近的几何形式。我正在尝试以 3D 方式绘制它(或重新绘制线条),如果您有任何可以帮助我的想法,将不胜感激, 谢谢
我想我明白你的问题是什么,你想要它画出夸张的线条,但又想要它以 3D 形式完成。
尝试将 line
切换为 triangle
(这将需要 2 个额外参数),或 sphere
(这将需要半径。
这应该很有希望。