POV-Ray : Newsgroups : povray.advanced-users : Inverse of matrix? Server Time
23 Dec 2024 18:55:36 EST (-0500)
  Inverse of matrix? (Message 1 to 9 of 9)  
From: SharkD
Subject: Inverse of matrix?
Date: 14 Nov 2009 23:27:52
Message: <4aff8348@news.povray.org>
I have a matrix:

matrix
<
	CamR.x, CamR.y, CamR.z,
	CamU.x, CamU.y, CamU.z,
	CamD.x, CamD.y, CamD.z,
	CamL.x, CamL.y, CamL.z
 >

What is the inverse?

Thanks.

Mike


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 02:45:44
Message: <4affb1a8@news.povray.org>
On 11/14/2009 11:27 PM, SharkD wrote:
> I have a matrix:
>
> matrix
> <
> CamR.x, CamR.y, CamR.z,
> CamU.x, CamU.y, CamU.z,
> CamD.x, CamD.y, CamD.z,
> CamL.x, CamL.y, CamL.z
>  >
>
> What is the inverse?
>
> Thanks.
>
> Mike

Nevermind. I found some code to do it here:

http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/index.htm

Do I need to flip the POV-Ray matrix first? In POV-Ray, translation 
occurs in the last *row*, whereas in the page I linked to translation 
occurs in the last *column*.

Mike


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 02:54:50
Message: <4affb3ca$1@news.povray.org>
On 11/15/2009 2:45 AM, SharkD wrote:
> Nevermind. I found some code to do it here:
>
> http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/index.htm
>
>
> Do I need to flip the POV-Ray matrix first? In POV-Ray, translation
> occurs in the last *row*, whereas in the page I linked to translation
> occurs in the last *column*.
>
> Mike

Also, when applying the matrix to a vector instead of an object (i.e. 
using an array), do I multiply by a 1x3 matrix? Is this matrix vertical 
or horizontal?

Mike


Post a reply to this message

From: clipka
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 05:52:37
Message: <4affdd75$1@news.povray.org>
SharkD schrieb:
> I have a matrix:
> 
> matrix
> <
>     CamR.x, CamR.y, CamR.z,
>     CamU.x, CamU.y, CamU.z,
>     CamD.x, CamD.y, CamD.z,
>     CamL.x, CamL.y, CamL.z
>  >
> 
> What is the inverse?

transform {
   matrix <
      CamR.x, CamR.y, CamR.z,
      CamU.x, CamU.y, CamU.z,
      CamD.x, CamD.y, CamD.z,
      CamL.x, CamL.y, CamL.z
   >
   inverse
}

:-P


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 15:00:23
Message: <4b005dd7@news.povray.org>
On 11/15/2009 5:51 AM, clipka wrote:
> :-P

OK, wow. That was easy!

However, I still need to know how to apply the matrix to a coordinate or 
vector as opposed to an object.

Mike


Post a reply to this message

From: clipka
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 15:31:46
Message: <4b006532$1@news.povray.org>
SharkD schrieb:
> On 11/15/2009 5:51 AM, clipka wrote:
>> :-P
> 
> OK, wow. That was easy!
> 
> However, I still need to know how to apply the matrix to a coordinate or 
> vector as opposed to an object.

#declare MyTransform = transform {
   matrix < ... >
}

#declare MyInverseTransform = transform {
   MyTransform // or directly specify the matrix here
   inverse
}

#include "transforms.inc"

#declare V2 = vtransform(V1, MyInverseTransform)
// or:
// #declare V2 = vinv_transform(V1, MyTransform)


(When applying the matrix to a direction vector - as opposed to a 
location vector, i.e. a point - make sure the matrix doesn't have a 
translation component, unless you're perfectly sure what you're doing.)


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 15:48:41
Message: <4b006929@news.povray.org>
On 11/15/2009 3:31 PM, clipka wrote:
> (When applying the matrix to a direction vector - as opposed to a
> location vector, i.e. a point - make sure the matrix doesn't have a
> translation component, unless you're perfectly sure what you're doing.)

Awesome! I wasn't aware of the vtransform function. Thanks!

Mike


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 23:23:52
Message: <4b00d3d8@news.povray.org>
Is there an easy way to combine multiple transformations? I tried each 
of the following:

#local trans_c = transform
{
	transform {trans_a}
	transform {trans_b}
}

#local trans_c = transform
{
	trans_a + trans_c
}

#local trans_c = trans_a + trans_b


Mike


Post a reply to this message

From: SharkD
Subject: Re: Inverse of matrix?
Date: 15 Nov 2009 23:26:35
Message: <4b00d47b$1@news.povray.org>
On 11/15/2009 11:23 PM, SharkD wrote:
> Is there an easy way to combine multiple transformations? I tried each
> of the following:
>
> Mike

Nevermind. There was a typo in my working code. The first example works.

Mike


Post a reply to this message

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