Page 1 of 1

### Intersection of ray with quadric surface for hobby ray tracer

Posted: Fri Jan 20, 2017 7:48 pm
I'm looking into ways to add more shapes to my hobby path tracer, such as cylinder, cone, ellipse. So, I'm at this reference:
http://www.bmsc.washington.edu/people/m ... drics.html which is taken from Lindley book on ray tracing (which I also have, but without CD). It briefly explains generalized quadratic formula with A...J parameters and how to calculate normals.

While this could be what I need, there is no much detail on meaning of AJ parameters. For instance If I take ellipse, then ideally I would want to specify it in terms of 'a' and 'b' radius on the x and y exes respectively, origin and orientation (3x3 matrix).

Can anyone please point me to where to learn more about these AJs parameters or alternative (simple) approaches.

Thank you very much in advance.

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Fri Jan 20, 2017 9:10 pm
Here's an explanation of how to build up the 4x4 matrix for several quadric types: https://www.siggraph.org/education/mate ... inter4.htm

I believe that Glassner's 1980's book "Introduction to Ray Tracing" also has a paragraph on this.

There's a ray/quadric implementation in the ray tracing skeleton program of the programming course that I teach at University: https://vis.uni-koeln.de/raytracer0.html (the program itself won't compile out the box, making it compile is part of the students' task, anyhow, the "geoquadric" class should work right away).

Cheers, Stefan

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Fri Jan 20, 2017 9:44 pm
This here paper btw. uses quadrics to project 3-D ellipsoids to 2-D: https://pdfs.semanticscholar.org/df2e/0 ... b231e6.pdf

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Sun Jan 29, 2017 4:20 pm
The explanation behind general quadrics is not so simple and obvious. It does get quite tedious doing the math with 10 quadric coefficients and 12 more coefficients of a general affine transform.

If you feel like digging through the source code of another toy raytracer, I can offer an older experiment of mine:

http://www.vectorizer.org/boar/boarCore1.tar.bz2

http://www.vectorizer.org/boar/boarCore ... nt.tar.bz2

The first tarball is just the source. In transform.c++ is code for the usual rotations and translations, as well as concatenating such transforms. In quadric.c++ there are initialization routines for common shapes (sphere, cylinder, cone) and less common shapes (slab, lathe, product of planes). The quadric class also knows how to transform a quadric given an affine transform.

The second tarball contains an explanation of the scene description language (heavily inspired by PoV-Ray, http://www.povray.org), and an example scene file. I think the three syntaxes (in the doc, in the actual parser, and in the example scene) do slightly differ from each other - this is not a proper release, sorry.

The source code is moderately commented. I have since abandoned this particular approach, but will gladly answer any questions you might have.

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Thu Feb 02, 2017 8:49 pm
Thanks a lot! I'm still testing, but it started to work now.
Also found relatively simple and compact ref here: https://people.cs.clemson.edu/~dhouse/c ... adrics.pdf
My next challenge is solid constructions.

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Fri Feb 03, 2017 5:02 am
asyrov wrote:My next challenge is solid constructions.
My code above is not a good reference for constructive solid geometry. It does have a rather inefficient implementation; but that would only make sense in conjunction with spatial subdivision (where the voxels contained only pruned CSG subtrees).

### Re: Intersection of ray with quadric surface for hobby ray tracer

Posted: Thu Apr 06, 2017 9:39 am
BRL-CAD has OpenCL code for quite a lot of primitives: