POV-Ray : Newsgroups : povray.advanced-users : Matrix question : Re: Matrix question Server Time
4 May 2024 23:38:28 EDT (-0400)
  Re: Matrix question  
From: Josh English
Date: 22 Dec 2000 14:45:04
Message: <3A43AF3F.7B72DA6C@spiritone.com>
Silly me, I already solved the problem of how to find the inverse of a matrix to
deal with a collision model for POV-Ray wth the help of a friend:

Here is the relevant code:
// The POV_Ray representation of the matrix that we need to find the inverse of.
#declare bX = <1,-0.05,0>;
#declare bY = <-0.5,0.5,0>;
#declare bZ = <0,0,1>;
#declare bC = <0,0,0>;

// THe 16 statements to fill out the 16 elements of the inverse
// // New system devised by David Jones
#declare dp = bX.x*bY.z - bX.z*bY.x;
#declare dq = bX.z*bY.y - bX.y*bY.z;
#declare dr = bX.x*bY.y - bX.y*bY.x;
#declare dt = bX.y*bZ.x - bZ.y*bX.x;

#declare dy = bZ.x*dq - bZ.y*dp + bZ.z*dr;
#declare dx = bC.x*dq - bC.y*dp + bC.z*dr;

#declare c11 = (bY.y * bZ.z - bY.z * bZ.y)/dy;
#declare c12 = (bX.z * bZ.y - bX.y * bZ.z)/dy;
#declare c13 = (bX.y * bY.z - bX.z * bY.y)/dy;
#declare c14 = 0;

#declare c21 = (bY.z * bZ.x - bY.x * bZ.z)/dy;
#declare c22 = (bX.x * bZ.z - bX.z * bZ.x)/dy;
#declare c23 = (bX.z * bY.x - bX.x * bY.z)/dy;
#declare c24 =0;

#declare c31 = (bY.x * bZ.y - bY.y * bZ.x)/dy;
#declare c32 = (bX.y * bZ.x - bZ.y * bX.x)/dy;
#declare c33 = (bX.x * bY.y - bX.y * bY.x)/dy;
#declare c34 = 0;

#declare c41 = -1*(bC.x * c11 + bC.y * c21 + bC.z * c31);
#declare c42 = -1*(bC.x * c12 + bC.y * c22 + bC.z * c23);
#declare c43 = -1*(bC.x * c13 + bC.y * c23 + bC.z * c33);
#declare c44 = 1;

This seemed to work after all of my tests, and it was a lot faster

Josh


Post a reply to this message

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