---------------
Question 1: I tried making a hyperboloid from one piece using the formule x^2+y^2-z^2=1. So far no problems, but I wanted to view it from the outside. This means the point of origin must lie outside the object with the equation x^2+y^2-z^2=1. I thought that that would be pretty easy to do by changing to the origin coördinates {ox,oy,oz} to {0,2,0} and then I could find out later how to make sure that the position of origin is relative to the rotation angles in such a way that the camera always look at the object.
But after I changed {ox,oy,oz} to {0,2,0} (you can do this changing the following line:
to
Frame:
ox=0;oy=0;oz=0;
The view isn't like the object I intended at all. What have I done wrong?
Frame
ox=0;oy=2;oz=0;
The code of the dynmov:
---------------
init
pi=acos(-1);rx=1.57;ry=1.57;rx=0;ry=0;rz=0;rxo=0.05;ryo=0.01;rzo=rand(10)/100-0.05
frame
rx=rx+rxo;rxo=rxo*0.9+rxc*0.1;rxc=rxc*0.99;
ry=ry+ryo;ryo=ryo*0.9+ryc*0.1;
rz=rz+rzo;rzo=rzo*0.9+rzc*0.1;
cx=cos(rx);sx=sin(rx);
cy=cos(ry);sy=sin(ry);
cz=cos(rz);sz=sin(rz);
ox=0;oy=0;oz=0;
c1=ox*ox+oy*oy-oz*oz-1;
beat
rxc=rand(40)/500-0.05;
ryc=rand(40)/500-0.05;
rzc=rand(40)/500-0.05;
point
x1=x;y1=y;
x1d=x1*cz-y1*sz;y1d=x1*sz+y1*cz;
y2d=y1d*cx-sx;z2d=y1d*sx+cx;
x3d=x1d*cy-z2d*sy;z3d=x1d*sy+z2d*cy;
a1=x3d*x3d+y2d*y2d-z3d*z3d;b1=2*(x3d*ox+y2d*oy-z3d*oz);
ki=sqrt(b1*b1-4*a1*c1)/(2*a1);
k1=-b1/(2*a1)+ki;
k2=-b1/(2*a1)-ki;
k=min(k1,k2);
ix=k*x3d+ox;iy=k*y2d+oy;iz=k*z3d+oz;
x=abs(atan2(ix,iy))/pi*2;y=iz*3;
alpha=1.3-abs(iz)/2;
Question 2: I wanted to do a triangular tunnel by defining three planes with the following formulas:
-x+y=2
x+y=2
y=-sqrt(2)
This should give you a triangle tunnel, but instead I get something very strange. There are three planes, which will form a triangle when extended, but on and around the places where the triangle sides should meet, there are some strange planes that go to infinity. Making the k1, k2 and k3 absolute solves the problem, but gives you a six-sided tunnel. I want a three-sided one.
I think the problem has to do with the -infinity outcomes for k1, k2 and k3, but I can't get rid of those without making the tunnel six-sided. The code of the dynmov:
init
pi=acos(-1);rx=1.57;ry=1.57;rx=0;ry=0;rz=0;rxo=0.05;ryo=0.01;rzo=rand(10)/100-0.05
frame
rx=rx+rxo;rxo=rxo*0.9+rxc*0.1;rxc=rxc*0.99;
ry=ry+ryo;ryo=ryo*0.9+ryc*0.1;
rz=rz+rzo;rzo=rzo*0.9+rzc*0.1;
cx=cos(rx);sx=sin(rx);
cy=cos(ry);sy=sin(ry);
cz=cos(rz);sz=sin(rz);
ox=0;oy=0;oz=0;
beat
rxc=rand(40)/500-0.05;
ryc=rand(40)/500-0.05;
rzc=rand(40)/500-0.05;
point
x1=x;y1=y;
x1d=x1*cz-y1*sz;y1d=x1*sz+y1*cz;
y2d=y1d*cx-sx;z2d=y1d*sx+cx;
x3d=x1d*cy-z2d*sy;z3d=x1d*sy+z2d*cy;
k1=(2+ox-oy)/(y2d-x3d);
k2=(2-ox-oy)/(y2d+x3d);
k3=(-sqrt(2)-oy)/y2d;
k=min(k1,min(k2,k3));
ix=k*x3d+ox;iy=k*y2d+oy;iz=k*z3d+oz;
x=ix;y=iz;
alpha=1.3-abs(iz)*0.5;