nixa
6th September 2002 12:29 UTC
could you help me out whith this scope
This was an experiment on making 3D objects whith coordinates off all points being known. I thought i'll make a simple piramide first for test.
This is how it schould work:
whith points being:
A(0,0,0);
B(1,0,0);
C(0.5,0,sqrt(3)/2);
D(0.5,sqrt(6)/3,sqrt(3)/6);
to drow a piramid lines schould go:
A->B->C->A->D->B->C->D
So I made x1,y1 and z1 do this for each of 8 values of i the rest is just 3D->2D code.
The problem is it doesnt work.
Could someone help me out.
init:
n=8;sp=0.1
on beat:
tx=rand(201)/100-1;ty=rand(201)/100-1;tz=rand(201)/100-1;
per frame :
kx=kx+tx*sp;ky=ky+ty*sp;kz=kz+tz*sp; sx=sin(kx);
sy=sin(ky);sz=sin(kz);
cx=cos(kx);cy=cos(ky);cz=cos(kz);
per point:
i=i*8+1;
x1=equal(i,1)*0+equal(i,2)*1+equal(i,3)/2+equal(i,4)*0+equal(i,5)/2+equal(i,6)*1+equal(i,7)/2+equal(i,8)/2;
y1=equal(i,1)*0+equal(i,2)*0+equal(i,3)*0+equal(i,4)*0+equal(i,5)*sqrt(6)/3+equal(i,6)*0+equal(i,7)*0+equal(i,8)*sqrt(6)/3;
z1=equal(i,1)*0+equal(i,2)*0+equal(i,3)*sqrt(3)/2+equal(i,4)*0+equal(i,5)*sqrt(3)/6+equal(i,6)*0+equal(i,7)*sqrt(3)/2+equal(i,8)*sqrt(3)/6;
x1=x1*2-1;y1=y1*2-1;z1=z1*2-1;
x2=x1*cz-y1*sz;y1=x1*sz+y1*cz;
y3=y2*cx-z1*sx;z3=y2*sx+z1*cx;
x=x2*cy-z3*sy;y=x2*sy+z3*cy;
Jaheckelsafar
8th September 2002 05:13 UTC
I think a cube would be easier to make. All you do is make a square and extrude it. It's probably also easier to make you 3D shape with an equation thsn manually setting the points like you did.
Your rotation stuff looks good, but I don't think you can change the value of i like you do in the beginning of the per point section..
jheriko
20th September 2002 06:00 UTC
solution
here is some code to draw a pentagon though specific points (its taken from one of my presets) you can modify this scope quite easily to make a pyramid. (i've highlighted the most important bits).
init:
n=6;phi=(sqrt(5)+1)*0.5;iphi=phi-1;rx=0;ry=0;rz=0;
on beat:
t=if(equal(move,1),if(equal(rand(12),1),0,t),t);dt=if(equal(move,1),(rand(50)+25)/500,dt);
frame:
t=t+dt;move=if(below(t,3.141593),1+0.5*sin(t),1);rx=rx+0.01;ry=ry-0.01;q=-1;crz=cos(rz);srz=sin(rz);cry=cos(ry);sry=sin(ry);crx=cos(rx);srx=sin(rx)
pixel:
q=q+1;
x1=if(equal(q,0),1,x1);
y1=if(equal(q,0),1,y1);
z1=if(equal(q,0),1,z1);
x1=if(equal(q,1),phi,x1);
y1=if(equal(q,1),0,y1);
z1=if(equal(q,1),iphi,z1);
x1=if(equal(q,2),1,x1);
y1=if(equal(q,2),-1,y1);
z1=if(equal(q,2),1,z1);
x1=if(equal(q,3),0,x1);
y1=if(equal(q,3),-iphi,y1);
z1=if(equal(q,3),phi,z1);
x1=if(equal(q,4),0,x1);
y1=if(equal(q,4),iphi,y1);
z1=if(equal(q,4),phi,z1);
x1=if(equal(q,5),1,x1);
y1=if(equal(q,5),1,y1);
z1=if(equal(q,5),1,z1);
x1=x1*move;
y1=y1*move;
z1=z1*move;
x2=x1*crz-y1*srz;
y2=x1*srz+y1*crz;
z2=z1;
x3=x2*cry+z2*sry;
y3=y2;
z3=-x2*sry+z2*cry;
x1=x3;
y1=y3*crx-z3*srx;
z1=y3*srx+z3*crx;
x=x1/(3+z1);
y=y1/(3+z1);
x=x*h/w;
i notice that your pyramid is infact a tetrahedron. these presets might interest you too (you can draw a solid tetrahedron if you adapt the code from the last one).
http://www.deviantart.com/deviation/708523
http://www.deviantart.com/deviation/719927
hope this all helped!