0

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!

peppone
  • 85
  • 6
  • Can I suggest you first model a flat ring similar to the torus, so it is a circular wall (rather than a disk like a planet's ring). Suppose the axis of the torus/ring is vertical, and the surface normal always points radially. Then modify it so that the angle of the surface normal depends on the angle around the vertical axis, giving the strip a 180° twist as it goes 360° around the vertical axis. Not sure about the ray tracing part but this could define the surface for you. – Weather Vane Jan 18 '20 at 23:18
  • Normally if you can define an intersection function you can use it in a ray tracer. What's so special about a Möbius strip mathematically? It's like a wonky torus. – tadman Jan 19 '20 at 01:39

3 Answers3

1

Yes it is possible to render a mobius strip with a raytracer.

mobius

peppone
  • 85
  • 6
0

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: enter image description here

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?

peppone
  • 85
  • 6
  • I am sure that my rendering corresponds to the mobius surface, can someone help me to obtain only the mobius strip from the surface? – peppone Jan 28 '20 at 00:57
0

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)

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32564538) – yoduh Aug 30 '22 at 01:24