|
![](/i/fill.gif) |
Thomas Willhalm wrote:
>
> "Rune S. Johansen" <run### [at] get2net dk> writes:
>
> > Normally a matrix can transform
> > an object so the point x can become
> > P1, y can become P2, z can become
> > P3 and the origin becomes P4.
> > How can I do this thing backwards?
> > I.e. P1 becomes x, P2 becomes y,
> > P3 becomes z, and P4 becomes the
> > origin. The way I tried it I only
> > got a lot of divide by zero warnings.
>
> In practice, the matrix keyword in povray divides into a
> - a linear function given by the matrix entries Val00 to Val22
> - a transformation given by Val30 to Val32
^^^^^^^^^^^^^^
This should be "translation."
> If you want to calculate the inverse function, you have to
> - invert the 3x3 matrix Val00 to Val22
> - take the negative of the vector Val30 to Val32
Pretty much; IIRC, the inverted 3x3 has to be applied to the
negated vector to yield the final result. I've been scribbling
notes for a suite of macros to fiddle with matrices, mainly
because (a) there is no one-stop-shop for inverting a general
matrix in POV-Ray (without doing the math oneself), (b)
POV-Ray does not provide access to the elements within a
transform, and (c) I wanted to provide a macro with the package
to explicitly perform shears.
> How to calculate a inverse matrix should be described in every
> linear algebra book. Keep in mind, that not every matrix is
> invertible.
Yes, but the matrices that are not invertible are not valid for
use in transformations. They're easy to spot: The first nine
elements, when taken as a 3x3 matrix, yields a determinant = 0.
If you give one of these to POV-Ray, you'll get a fatal error.
Regards,
John
Post a reply to this message
|
![](/i/fill.gif) |