# Quadric surfaces and transformation matrices

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

• This isn't a complete answer, but this has many of the elements that you are looking for, with several links to the relevant literature. – Damien Apr 25 '13 at 1:06

$$Q'=M^{-1}Q(M^{-1})^t$$ with $$X=\left[\begin{array}{cccc}x\\y\\z\\1\end{array}\right], ~ Q = \left[ \begin{array}{cccc} a & b & c & d \\ b & e & f & g\\ c & f & h & i \\ d & g & i & j \end{array} \right], ~ X^tQX=0,$$
and $X$ being your $v^t$.
Okay, let's try something like that: $$C' = MCM^T$$ with $M$ being the sought pose and $(C,C')$ the quadrics in correspondence.
As $C$ is a real & symmetric matrix, if we apply an Eigen decomposition, we can write: $$V'D'(V')^T = MVD(V)^TM^T$$ Let's re-arrange: $$V'D'(V')^T = MV(D)(MV)^T$$ Because a rigid transformation would not change the Eigenvalues, I expect that $$V' = MV$$ and from here: $$M = V'V^{-1}$$