I decided to try to make the camera move. So I surfed the net and found deferent ways to solve the a4*k^4+a3*k^3+a2*k^2+a1*k+a0 problem and since i only need k calculated to 3-4 digits i figured that newton-raphson method would be the fastest.
I almoast figured out how it works but need some help. As i understood the newton-raphson method is a recursive function
x(n+1)=xn+f(xn)/f'(n)
Can someone tell me how is f' connected to f function?
f' is the derivative of f
for a quartic function:
f(k) = a4*k^4+a3*k^3+a2*k^2+a1*k+a0
f'(k) = 4*a4*k^3+3*a3*k^2+2*a2*k+a1
I tried newton raphson myself once and the accuracy was pretty bad. You also have to know that there can be up to 4 solutions, and there is no way to know which one you'll get if you just pick an initial value at random.
For me it didn't work out very well, but the problem I had was much more complicated than a simple torus.
Well my experiments all ended in vain. It was a hell lot of work just to seperate everything by k and what i got doesnt look a bit like what its supose to, runs 10 fps and sucks in general. Im preety sure now that the problem needs to be aproached by a diferent angle (3D polar coordinates are my best gues for now) and will let you know if I make anything.
Oh my god!
DM is ..... LARGE
I dunno about you but I like it, moves smoothly.
but sometimes it goes out of view.
Ehhh, i dont know how you guys can make soo good stuff...
The camera doesn't move too far from the origin. I would help you out, but I don't know that much about 3-D DMs. It's still nice though.
very nice, im gettin pretty decent at 3d DMs buti still have no fckin clue about raytracing,
btw jack, a pentagram is usually an upside down star 😛
Btw, using pow() with integer powers is a waste of speed... especially for polynomials.
ak^4 + bk^3 + ck^2 + dk + e
can be written as:
(((a*k + b)*k + c)*k + d)*k + e
Much faster and uses only additions/multiplications. Pow uses logarithms and exponentials I believe (take logarithm, multiply with exponent, calculate exponential).
Hkkhmm Raz_001.
It depends...
The pentagram of the good guys is like mine is.
But u can see eavel pentagram down there (I was 2 lazy to make circle oround it).
Now that is one seriously broken diseased lookin pentagram lol
heres a REALLY evil lookin pentagram
Try makin this in avs 😛 (withut a picture)
Uhm... so it's a view inside a ring? I like the 1st version more, because the second just works so damn slow and doesn't seem to be any different... Nice work nixa, maybe you should add a 3D starfield into it to make it look like it was a space station or something 🙂
Im not there yet but here is an object very similar to the torus. Its composed out of 2 tunnels and a plane. The bigest downsides of this version are ugly adges and high grid size.
Just found out a litle bug. To fix it replace 6th lone whith:
k2=oy/dy-ln;k2=k2*below(sqrt(sqr(-ox+dx*k2)+sqr(-oz+dz*k2)),dr);
or just add theat -ln part to the code.
And yeah i know the code is highly unoptimised but im too lazy to fix it now.
and damn that shadowing is cool 😁
though i still don't see why you can't make the camera move outside the original torus...unless it's a "fake" torus (sorta like the fake d=tan(d) sphere)
this looks pretty damn good, if you could just make it move around a bit more and add some effect's it'd be good enough for me 🙂
The second torus (with newton raphson) definitely is 'fake'... I tried positioning the camera above the torus and looking down, but instead of a ring I got nothing (and yes I was sure I was looking in the right direction, I used increments for the angle up to pi/2).
Torus 3 is much better (but not a torus 😉), but there seems to be a bug too. I think your planes are not positioned correctly or you might've made a typo. When the side passes in front of the camera, it seems to extend a bit, as if the outer cylinder is too wide or too high.
(this is with the -ln fix btw)
If you change the viewing angle by multiplying your initial z coordinate, holes appear (if you're raytracing this correctly, this shouldn't be happening)
dz=1.5*sy+cy*dx;dx=1.5*cy-sy*dx;
Have you considered doing actual gouraud shading? The normals are very easy to calculate for all your points, so this shouldn't be too much of an issue.
If you included shading, this would make an awesome LOTR preset. However if I were you, I would replace the outer cylinder with a cut off sphere. That way it looks more rounded at the outside. Another problem is the ugly edges, but you could avoid them by not texturing the ring and using the shading values as texture map instead(*). Then you could additively blend a synched regular sphere DM on top of it with the ring's text on it (this DM can be very simple and low-gridsize).
Oh and Atero: a torus is defined by a quartic equation, which is pretty near impossible to solve analytically in AVS. With newton-raphson it's easier, but you have to make sure you're finding the correct point, and not some point behind the camera.
When the camera is in the torus' center, the equation is reduced to a regular quadric I think.
Same reason Jheriko's rounded-rectangular tunnel can only be viewed from the center.
(*) Here's an unfinished preset which uses this technique. Every sphere has two differently colored lights pointing at it. Basically it draws a gradient from black to a color in one column of pixels, and draws another gradient from black to another color in the column of pixels next to that. The x-coordinate defines the influence of light1 or light2, while the y-coordinate defines the brightness.
Look at the original texture (the small thing in the center behind the spheres) and how it is mapped to the spheres.
Here is the latest version. I fixed the plane displacement bug, added a ray of light shooting thrue the center and maped the plane circulary.
As soon as I find some more time ill try to intersect a sphere and an object you get by rotating a hyperbola(its discribed by
abs((x/a)^2+(y/b)^2-(z/c)^2)=1 but im not sure what is it called) this schould make an almoast perfect(fake) torus.
Unconed that is a really cool preset(the light and how they can go behind each other). Ill look at the coding more carefully later.
Well considering a lathed hyperbola is a second degree object (quadric) just like a cylinder and a sphere, you shouldn't have much trouble raytracing it.
Btw I'm not sure if you figured this out yet, but in my description of sphere with tunnel, I said you had to retrace all points for which the distance to the central axis is smaller than the radius, or (sqr(px) + sqr(pz)) < sqr(R) or something like that. However I forgot that you can simply check the y coordinate as well, without the squares 🙂.
The same goes here of course.
If you make the cut-off point right, you won't need planes at the top or bottom, only the sphere and hyperboloid.
You forgot to adjust the aspect ratio btw... looks squished 🙂
nixa, it's kinda hard to tell that the light is shooting through the center of the ring. It looks more like the background just has flashing lines.
Damn I hate it when I miss most of a good thread... nice to see that you tryed my suggestion of the Newton-Raphson, but did you try out the secant method... it converges much faster than NR.
xn+1=xn-(f(xn)*(xn-xn-1))/(f(xn)-f(xn-1))
The only downside is that you need to start with two approximations. To increase the accuracy you may want to find a few quadratics or linears which approximate the quadric for different ranges of x, then you could find two guesses which are reasonably close to the correct solution. Alternatively you could use one approximation and get the other from a single iteration of NR.
For those who were confused by Jheriko's formula:
X(n+1)=Xn-{f(Xn)*{Xn-X(n-1)}}/{f(Xn)-f(X(n-1))}
btw, if f is secant:
X(n+1)=Xn-{sec(Xn)*{Xn-X(n-1)}}/{sec(Xn)-sec(X(n-1))}
<edit> oopsie, forked up the formula 🙄 it's better now </edit>
I doubt the secant formula has anything to do with the goniometric 'secant' (i.e. 1/cosine), but more likely refers to how the line connecting f(Xn) and f(Xn-1) slices f (latin: secare = to cut, if my latin's still good).