POV-Ray : Newsgroups : povray.general : Projective transform matrix : Re: Projective transform matrix Server Time
31 Jul 2024 12:17:37 EDT (-0400)
  Re: Projective transform matrix  
From: John VanSickle
Date: 18 Feb 2007 19:46:29
Message: <45d8f365$1@news.povray.org>
Benoit wrote:
> Hi All,
> 
> The "matrix" construct allows one to enter a matrix for a 3D affine
> transform. Internally, however, what is stored and used is a linear
> transform in the 4D projective space. The 4x4 matrix used for internal
> purposes is composed of the 12 coefficients provided by the user in the
> "matrix" construct, plus "0 0 0 1" for the last line.
> 
> Is there any way that one could enter directly the 16 coefficients of the 4D
> projective transform? This would for example enable the transformation of
> cylindrical elements into cones, or more complex elements (e.g. height
> fields) into their cone version...

No.  The type of transformation you describe is non-linear, which is not 
within the capability of any ordinary matrix.

The main problem with using a non-linear transform in POV-Ray is that a 
non-linear transform can have more than one inverse, or possibly no 
inverse, and POV-Ray requires its transforms to have exactly one 
inverse.  (This is also the reason that a scaling value of zero results 
in an error; such matrices have no inverse.)

OpenGL (and other renderers), make use of the full 4x4 matrix, because 
they use the camera transform to to perspective calculations as well as 
to transform the camera space into screen coordinates.  The vector 
<x,y,z,1> is fed to the camera matrix, resulting in a new vector 
<x',y',z',w>.

The perspective effect is achieved by dividing w into x', y', and z'. 
The projection matrix is designed so that objects that are farther away 
from the camera will have a higher value for w, and objects that are 
closer will have a lower value.  This usually involves a fourth column 
of the form <a,b,c,0>.  Dividing the w into the rest of the vector 
causes the father objects to be smaller then the closer ones.

When the matrix is an orthographic projection, the fourth column is the 
same constant <0,0,0,1> as POV-Ray uses for its object transformations; 
as a consequence, the w value is always 1, and as a consequence objects 
do not change in screen dimensions as they move closer or farther away 
from the camera viewpoint.

The scale, rotate, and translate transforms have no need for this 
normalization step, and so the fourth column is always the constant 
value you mention, and remains so no matter how many transforms are applied.

Hope this helps,
John


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.