Reputation: 85
In my raytracer all surfaces are centered at the origin and oriented on Y axis. Displacement, rotations and resizing are obtained through transformation matrix applied on rays.
I recently rendered a torus in my ray-tracing using its Cartesian equation:
(x^2 + y^2 + z^2)^2 - 2 * (r1^2 + r2^2) * (x^2 + y^2 + z^2) + 4 * r1^2 * y^2 + (r1^2 - r2^2)^2
to which I replaced every point with the ray equation:
ex: X = Ray.ori.x + T * Ray.dir.x;
With the ray components replaced in the equation, I got the 5 coefficients of my quartic function which can be used to find the equation roots (the T intersections) with a 4th degree polynomial solver algorithm.
I was wondering if a mobius strip can be rendered the same way. My research did not bring up much, I found some Raytracing codes using cubic equations but copying the 4 coefficients led me to incomprehensible forms and artifacts.
Could you help me to render it? Also advice to render it with another method is welcome.
Thanks!
Upvotes: 0
Views: 548
Reputation: 1
Your last post is right. You are indeed rendering the good 3d shape.
To get your Möbius strip, you only need to select the right portion.
You may want to add up in a 3d grapher tool your cartesian equation with the parametric one that you can found on Wikipedia.
You will then see where it is ;)
(It's center is the origin and has a radius of 1.5)
Upvotes: 0
Reputation: 85
I took the (Cartesian) cubic equation of the mobius from: mathworld then I replaced the x,y and z of mobius with the ray equation.
However the result is this one:
Here is the code to calculate the mobius coefficients.
double x = ray.ori.x;
double y = ray.ori.y;
double z = ray.ori.z;
double i = ray.dir.x;
double j = ray.dir.y;
double k = ray.dir.z;
double c[4];
double R = 1.;
int solutions;
c[3] = (i * i) * j - 2. * (i * i) * k + (j * j * j) - 2. * (j * j) * k + j * (k * k);
c[2] = (i * i) * y - 2. * (i * i) * z + 2 * i * j * x - 2. * i * k * R - 4. * i * k * x + 3. * (j * j) * y - 2. * (j * j) * z - 4. * j * k * y + 2. * j * k * z + (k * k) * y;
c[1] = - 2. * i * R * z + 2 * i * x * y - 4. * i * x * z - j * (R * R) + j * (x * x) + 3. * j * (y * y) - 4. * j * y * z + j * (z * z) - 2. * k * R * x - 2 * k * (x * x) - 2. * k * (y * y) + 2. * k * y * z;
c[0] = - (R * R) * y - 2. * R * x * z + (x * x) * y - 2. * (x * x) * z + (y * y * y) - 2. * (y * y) * z + y * (z * z);
Maybe I'm rendering the entire surface that extends to infinity? How to get the mobius strip in this case?
Upvotes: 0