Intersection of ray with quadric surface for hobby ray tracer back
Board:
Home
Board index
Raytracing
General Development
(L) [2017/01/20] [ost
by asyrov] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!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:
[LINK http://www.bmsc.washington.edu/people/merritt/graphics/quadrics.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.
(L) [2017/01/20] [ost
by szellmann] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!Here's an explanation of how to build up the 4x4 matrix for several quadric types: [LINK https://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter4.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: [LINK 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
(L) [2017/01/20] [ost
by szellmann] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!This here paper btw. uses quadrics to project 3-D ellipsoids to 2-D: [LINK https://pdfs.semanticscholar.org/df2e/07f9482e7c6b18e6f4dca3d00a0504b231e6.pdf]
(L) [2017/01/29] [ost
by hobold] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!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:
[LINK http://www.vectorizer.org/boar/boarCore1.tar.bz2]
[LINK http://www.vectorizer.org/boar/boarCore1supplement.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, [LINK 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.
(L) [2017/02/02] [ost
by asyrov] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!Thanks a lot! I'm still testing, but it started to work now.
Also found relatively simple and compact ref here: [LINK https://people.cs.clemson.edu/~dhouse/courses/405/notes/quadrics.pdf]
My next challenge is solid constructions.
(L) [2017/02/03] [ost
by hobold] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!>> 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).
(L) [2017/04/06] [ost
by ziu] [Intersection of ray with quadric surface for hobby ray tracer] Wayback!BRL-CAD has OpenCL code for quite a lot of primitives:
[LINK https://svn.code.sf.net/p/brlcad/code/brlcad/trunk/src/librt/primitives/]
We are still working on porting primitives over but this is what we have already:
 an equation solver (solves quartic, cubic, and quadric equations).
 ray-primitive and surface normal code for: Bag o' Triangles (trimeshes), Arbitrary Polyhedrons, Elliptical Hyperboloids, Generalized Ellipsoids, Elliptical Paraboloids, Elliptical Torus, Right Elliptical Cylinders, Right Hyperbolic Cylinders, Right Parabolic Cylinders, Spheres, Truncated General Cones, Torus, and more...
back