I'm currently facing a problem and I think I have found a solution to it. However, I'd be interested to hear your opinion or hints on this.
I have written geometric modeling software and I have users who want to define a number of different bodies (e.g. cylinders, spheres, ellipsoids etc.) by providing the coefficients of the general quadric surface equation:
$$ax^2 + 2bxy + 2cxz + 2dx + \dots=0$$
which in general can be written also using a coefficient matrix $Q$ and a row vector $v:$
$$v Q v^t$$
My solid modeler already provides various different objects like cylinders, ellipsoids etc. but they are defined in a canonical system (e.g. cylinder parallel to the $\,z\,$ axis) and carry a transformation matrix to place them at the right position for rendering.
In order to treat bodies defined by general quadrics I have to do two things:
1.) Determine which kind of surface has been defined
2.) Obtain the transformation matrix which will transform the respective surface to the position/orientation which is implicitly included in the quadrics coefficients.
After doing a bit of algebra I came up with the following idea for 2.)
I thought to tackle the issue via principal axis transformation. So I would first try to determine the eigenvalues and the eigenvectors for the coefficient matrix $Q.$ The matrix which is represented by the eigenvectors in its columns should transform my coefficient matrix into the canonical system.
If I take the inverse of this eigenmatrix then this should be my transformation matrix, or am I wrong here? The eigenvalues would eventually determine the magnitude of parameters like the radius for spheres & cylinders, the major or minor halfaxes for ellipsoids etc.
I'd appreciate to hear your thoughts on this or if somebody has a simpler solution I'd be happy to discuss this as well.
Thanks a lot Chris