POV-Ray : Newsgroups : povray.advanced-users : About determinands and n-dimensional cross products Server Time
26 Nov 2024 01:39:09 EST (-0500)
  About determinands and n-dimensional cross products (Message 1 to 8 of 8)  
From: Tor Olav Kristensen
Subject: About determinands and n-dimensional cross products
Date: 17 Aug 2001 21:30:02
Message: <3B7DC4F1.C18AF6E3@hotmail.com>
This might be a bit off topic, BUT it 
might trigger some ideas for some math-
interested POV-ers...


I've been thinking a little bit about the 
fact that this expression:

vdot(vA, vcross(vB, vC))

will give the determinant of an 3x3 matrix
made up from the three 3-dimensional row 
vectors; vA, vB and vC:

vA = <Ax, Ay, Az>
vB = <Bx, By, Bz>
vC = <Cx, Cy, Cz>

I.e. this matrix:

| Ax Ay Az |
| Bx By Bz |
| Cx Cy Cz |



Why is this so ?

I'm not really sure, but below is my attempt
to describe how I see this.

(Note that I suspect there to be some
"deeper" relations between the determinant
of a 3x3 matrix and the cross product of
two vectors in 3D-space, but I haven't
studied enough linear algebra to see this
relation. Now it's about 10 years since 
I studied a little linear algebra. So for
all I know, my scribbling below may either
be 1) rubbish or 2) common knowledge in 
higher degree linear algebra courses without
me being aware of it.)

But anyway - here I go:


The determinant of the matrix above can be
calculated like this:

 Ax*(By*Cz - Bz*Cy)
-Ay*(Bx*Cz - Bz*Cx)
+Az*(Bx*Cy - By*Cx)

And this expression can be rewritten like
this:

 Ax*(By*Cz - Bz*Cy)
+Ay*(Bz*Cx - Bx*Cz)
+Az*(Bx*Cy - By*Cx)

Now this starts to look like a simple dot
product between two 3D-vectors:

the first one being equal to vA:
<Ax, Ay, Az>

and the second equal to:
<By*Cz - Bz*Cy, Bz*Cx - Bx*Cz, Bx*Cy - By*Cx>

which is the same as the cross product of 
the two vectors vB and vC.
I.e.: vcross(vB, vC)

I now name this cross product vector vD.
It's components are then:

Dx = By*Cz - Bz*Cy
Dy = Bz*Cx - Bx*Cz
Dz = Bx*Cy - By*Cx

The dot product between vA and vD is equal
to:

Ax*Dx + Ay*Dy + Az*Dz

So:

 Ax*(By*Cz - Bz*Cy)
+Ay*(Bz*Cx - Bx*Cz)
+Az*(Bx*Cy - By*Cx) =
Ax*Dx + Ay*Dy + Az*Dz =
vdot(vA, vD) = 
vdot(vA, vcross(vB, vC))

(q.e.d.)


Notice now that each of the 3 components
of vD has similarities to what would be
the determinants of these three 2x2 sub-
matrices.

| By Bz |
| Cy Cz |

and

| Bx Bz |
| Cx Cz | 

and

| Bx By |
| Cx Cy |


I.e. the 3 determinants:

By*Cz - Bz*Cy
Bx*Cz - Bz*Cx
Bx*Cy - By*Cx


So I now choose to write the cross product
vector vD like this:

vD = vcross(vB, vC) =
<det(M0), -det(M1), det(M2)>

where M0, M1 and M2 are the three 2x2 sub-
matrices above. And det(Mn) means the 
determinant of the matrix Mn.

Now I'm thinking that if a 2-dimensional
vector cross product was defined, then
maybe one could express these determinants
with expressions consisting of 2-
dimensional dot products and cross products ?

E.g.: 

det(N) = vdot(vE, vcross(vF))

N is now a 2x2 matrix and vE and vF are
the two 2-dimensional vectors it is made
up from:

vE = <Ex, Ey>
vF = <Fx, Fy>

I.e. this matrix:

| Ex Ey |
| Fx Fy |


I'm choosing the cross product in 2D-space
to be made from only one vector, since 
no 2D-vector (except the null vector 
<0, 0>) can be orthogonal to two other 
2D-vectors (none equal) at the same time.

The cross product vector of two vectors 
in 3D-space is orthogonal to each of the
two vectors that it is the cross product
of.

I.e. if:

v2 = vcross(v0, v1)

then v2 is orthogonal to both v0 and v1.
This implies that

vdot(v2, v0) = 0 

and that:

vdot(v2, v1) = 0


Therefore I suggest that the 2 dimensional
cross product vector must be orthogonal to
the vector that it is the cross product 
vector of.

I.e. if:

vG = vcross(vF)

then here is two ways to form such a cross
product vector:

Either:

vG = <Fy, -Fx>

or:

vG = <-Fy, Fx>


Both solutions will satisfy this expression

vdot(vG, vF) = 0

which can be written like this:

vdot(<Gx, Gy>, <Fx, Fy>) = 0

or like this:

Gx*Fx + Gy*Fy = 0


Here's the result from the 1st solution:
Fy*Fx + (-Fx)*Fy =  Fx*Fy - Fx*Fy = 0

Here's the result from the 2nd solution:
(-Fy)*Fx + Fx*Fy = -Fx*Fy + Fx*Fy = 0

I like the 1st solution best, because if
one follows my idea further down the
dimensions, then the vector components of a
2-dimensional cross product vector can be
expressed with determinants of 1x1 matrices
following the same plus/minus sign-pattern
as above:

vG = vcross(vF) =
<det(P0), -det(P1)>

Where P0 and P1 are two 1x1 sub matrices
of the N matrix above:

| Fy |

and

| Fx |


We then get:

det(P0) = Fy

and:

det(P1) = Fx


Thus:

vG = <Fy, -Fx>


So now:

det(N) = vdot(vE, vcross(vF))
= vdot(vE, vG)
= Ex*Fy + Ey*(-Fx) = Ex*Fy - Ey*Fx

Which is the only type of determinand
expression that I'm able to see directly
if it is correct. And IIRC it is.

-------------------------------------------

Now I'm thinking about defining a cross 
product for the 4-dimensional space,
that will be useful for calculating the
determinants for 4x4 matrices and for
calculating a vector that is orthogonal
to 3 given 4-dimensional vectors.

I'll just follow the same pattern as above:

First I name this 4x4 matrix P:

| Hx Hy Hz Ht |
| Ix Iy Iz It |
| Jx Jy Jz Jt |
| Kx Ky Kz Kt |

which made up from these 4 row vectors:

vH = <Hx, Hy, Hz, Ht>
vI = <Ix, Iy, Iz, It>
vJ = <Jx, Jy, Jz, Jt>
vK = <Kx, Ky, Kz, Kt>


If:

vR = vcross(vI, vJ, vK) =
<det(Q0), -det(Q1), det(Q2), -det(Q3)>

then:

det(P) = vdot(vH, vR) =
vdot(vH, vcross(vI, vJ, vK))


Q0, Q1, Q2 and Q3 are all 3x3 sub-matrices
of the matrix P. Here they are:

| Iy Iz It |
| Jy Jz Jt |
| Ky Kz Kt |

| Ix Iz It |
| Jx Jz Jt |
| Kx Kz Kt |

| Ix Iy It |
| Jx Jy Jt |
| Kx Ky Kt |

| Ix Iy Iz |
| Jx Jy Jz |
| Kx Ky Kz |


I'm NOT going to show here that now
these statements are all true:

vdot(vR, vI) = 0
vdot(vR, vJ) = 0
vdot(vR, vK) = 0

I'm quite sure about that. (But I've
probably made some errors above, so 
someone might prove me wrong ;)


Making similar expressions for the 
5th dimension and higher dimensions
is now easy:
Just follow the pattern I've described.


Below is a POV-script that I've made to
experiment with these ideas.

Unfortunately the built in vector 
operators in POV-Ray; vdot() and vcross()
are not able to operate on the 4-
dimensional and 5-dimensional POV-
vectors. Therefore I have defined my 
own macro versions of these below. I've 
also made such macros for 2D- and 3D-
vectors in order to be able to try and
verify my theories above and to make it
easier to compare the macros for the
different dimensions.


Comments are welcome !


Btw.:
Can anyone tell me if it is at all
possible to extract a fifth component
from a 5D-color vector in POV ?
(This would be useful for 5D-macros.)

Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Copyright 2001 by Tor Olav Kristensen
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// 1-dimensional stuff

#macro DetM_1D(MM)

  MM[0]

#end // macro Det_1D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 = 
// 2-dimensional stuff

#macro Vdot_2D(vA, vB)
  
  (
    vA.u*vB.u + 
    vA.v*vB.v
  )

#end // macro Vdot_2D



#macro Vcross_2D(vA)

  #local M0 = array[1] {
                vA.y
              }
  #local M1 = array[1] {
                vA.x
              }

  < DetM_1D(M0), -DetM_1D(M1)>

#end // macro Vcross_2D



#macro DetM_2D(MM)

  Vdot_2D(MM[0], Vcross_2D(MM[1]))
    
#end // macro Det_2D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 = 
// 3-dimensional stuff

#macro Vdot_3D(vA, vB)
  
  (
    vA.x*vB.x +
    vA.y*vB.y +
    vA.z*vB.z
  )

#end // macro Vdot_3D



#macro Vcross_3D(vA, vB)

  #local M0 = array[2] {
                <vA.y, vA.z>,
                <vB.y, vB.z>
              }
  #local M1 = array[2] {
                <vA.x, vA.z>,
                <vB.x, vB.z>
              }
  #local M2 = array[2] {
                <vA.x, vA.y>,
                <vB.x, vB.y>
              }
              
  < DetM_2D(M0), -DetM_2D(M1),  DetM_2D(M2)>

#end // macro Vcross_3D



#macro DetM_3D(MM)
       
  Vdot_3D(MM[0], Vcross_3D(MM[1], MM[2]))

#end // macro DetM_3D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 = 
// 4-dimensional stuff

#macro Vdot_4D(vA, vB)

  (
    vA.x*vB.x +
    vA.y*vB.y +
    vA.z*vB.z +
    vA.t*vB.t
  )

#end // macro Vdot_4D



#macro Vcross_4D(vA, vB, vC)


  #local M0 = array[3] {
                <vA.y, vA.z, vA.t>,
                <vB.y, vB.z, vB.t>,
                <vC.y, vC.z, vC.t>
              }
  #local M1 = array[3] {
                <vA.x, vA.z, vA.t>,
                <vB.x, vB.z, vB.t>,
                <vC.x, vC.z, vC.t>
              }
  #local M2 = array[3] {
                <vA.x, vA.y, vA.t>,
                <vB.x, vB.y, vB.t>,
                <vC.x, vC.y, vC.t>
              }
  #local M3 = array[3] {
                <vA.x, vA.y, vA.z>,
                <vB.x, vB.y, vB.z>,
                <vC.x, vC.y, vC.z>
              }

  < DetM_3D(M0), -DetM_3D(M1),  DetM_3D(M2), -DetM_3D(M3)>

#end // macro Vcross_4D



#macro DetM_4D(MM)

  Vdot_4D(MM[0], Vcross_4D(MM[1], MM[2], MM[3]))

#end // macro DetM_4D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 = 
// Define a couple of macros to allow me to see the results

#macro PrintVector_4D(vA)

  #debug "< "
  #debug str(vA.x, 0, -1)
  #debug ", "
  #debug str(vA.y, 0, -1)
  #debug ", "
  #debug str(vA.z, 0, -1)
  #debug ", "
  #debug str(vA.t, 0, -1)
  #debug " >"

#end // macro PrintVector_4D



#macro PrintMatrix_4D(MM)

  #debug "\n{ "
  PrintVector_4D(MM[0])
  #debug ", \n  "
  PrintVector_4D(MM[1])
  #debug ", \n  "
  PrintVector_4D(MM[2])
  #debug ", \n  "
  PrintVector_4D(MM[3])
  #debug " }\n"
    
#end // macro PrintMatrix_4D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 = 
// Now check if the determinant of this matrix equals -795
// (As my HP-48SX says it is.)

#declare M44 =
array[4] { 
  <  2,  0,  6,  3>,
  <  8,  1, -4, -2>,
  <  0,  5,  7,  1>,
  <  5, -5, -4, -2>,
}

#debug "\n"
#debug "The determinant of this matrix:"
#debug "\n"

PrintMatrix_4D(M44)

#debug "\n"
#debug "Is equal to: "

#debug str(DetM_4D(M44), 0, -1)

#debug "\n"
#debug "\n"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =


Post a reply to this message

From: Ron Parker
Subject: Re: About determinands and n-dimensional cross products
Date: 18 Aug 2001 00:25:21
Message: <slrn9nrrhk.dvi.ron.parker@fwi.com>
On Sat, 18 Aug 2001 03:29:21 +0200, Tor Olav Kristensen wrote:
>(Note that I suspect there to be some
>"deeper" relations between the determinant
>of a 3x3 matrix and the cross product of
>two vectors in 3D-space, but I haven't
>studied enough linear algebra to see this
>relation.

Actually, there is.  We were taught that the cross product of two
vectors A and B is the determinant of the matrix given by:

[  x   y   z  ]
[  Ax  Ay  Az ]
[  Bx  By  Bz ]

where x, y, and z are the basis vectors and Ax, Ay, etc. are the components
of the A and B vectors.

Knowing that, it's easy to see the result you've noticed.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: About determinands and n-dimensional cross products
Date: 20 Aug 2001 05:32:28
Message: <3b80d92c$1@news.povray.org>
Tor Olav Kristensen wrote in message <3B7DC4F1.C18AF6E3@hotmail.com>...
> This might be a bit off topic, BUT

matrix has you ;)

> Btw.:
> Can anyone tell me if it is at all
> possible to extract a fifth component
> from a 5D-color vector in POV ?
> (This would be useful for 5D-macros.)

#local V=<1,2,3,4,5>;
#warning concat(str(V.filter,0,-1),"\n")

--
#macro Sig(A,B,X)_(A,B)_(B,X)_(X,A)#end#macro _(A,B)cylinder{<A.x,A.y,3>,<B.u,
B.v,3>.1,9}#end global_settings{max_trace_level 9}light_source{0 1}camera{up y
*4right-3*x}blob{_(<3,1>,<1,-5>)_(<2,-2>,<4,-2>)Sig(x,<-1,1.5>,<1,3>)_(z-1,z-4
)pigment{rgb 1}}box{-3 3pigment{rgb 0}finish{reflection 1}hollow} // POV-Ray31


Post a reply to this message

From: Warp
Subject: Re: About determinands and n-dimensional cross products
Date: 20 Aug 2001 06:12:19
Message: <3b80e282@news.povray.org>
Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
: #warning concat(str(V.filter,0,-1),"\n")

  Isn't filter the fourth component?

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: About determinands and n-dimensional cross products
Date: 20 Aug 2001 06:18:56
Message: <3b80e410@news.povray.org>
Wlodzimierz ABX Skiba wrote in message <3b80d92c$1@news.povray.org>...
> Tor Olav Kristensen wrote in message <3B7DC4F1.C18AF6E3@hotmail.com>...
> > Can anyone tell me if it is at all
> > possible to extract a fifth component
> > from a 5D-color vector in POV ?
> > (This would be useful for 5D-macros.)
>
> #local V=<1,2,3,4,5>;
> #warning concat(str(V.filter,0,-1),"\n")


sorry I forgot:
a) it works in megapov 0.6a - I think there is bug in POV 3.1
b) add #warning concat(str(V.transmit,0,-1),"\n")


--
#macro Sig(A,B,X)_(A,B)_(B,X)_(X,A)#end#macro _(A,B)cylinder{<A.x,A.y,3>,<B.u,
B.v,3>.1,9}#end global_settings{max_trace_level 9}light_source{0 1}camera{up y
*4right-3*x}blob{_(<3,1>,<1,-5>)_(<2,-2>,<4,-2>)Sig(x,<-1,1.5>,<1,3>)_(z-1,z-4
)pigment{rgb 1}}box{-3 3pigment{rgb 0}finish{reflection 1}hollow} // POV-Ray31


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: About determinands and n-dimensional cross products
Date: 20 Aug 2001 07:04:19
Message: <3b80eeb3@news.povray.org>
Warp wrote in message <3b80e282@news.povray.org>...
>Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
>: #warning concat(str(V.filter,0,-1),"\n")
>
>  Isn't filter the fourth component?


Yes, I just badly copy&pasted

--
#macro Sig(A,B,X)_(A,B)_(B,X)_(X,A)#end#macro _(A,B)cylinder{<A.x,A.y,3>,<B.u,
B.v,3>.1,9}#end global_settings{max_trace_level 9}light_source{0 1}camera{up y
*4right-3*x}blob{_(<3,1>,<1,-5>)_(<2,-2>,<4,-2>)Sig(x,<-1,1.5>,<1,3>)_(z-1,z-4
)pigment{rgb 1}}box{-3 3pigment{rgb 0}finish{reflection 1}hollow} // POV-Ray31


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: About determinands and n-dimensional cross products
Date: 20 Aug 2001 18:22:30
Message: <3B818D90.EC72494C@hotmail.com>
Wlodzimierz ABX Skiba wrote:
> 
> Wlodzimierz ABX Skiba wrote in message <3b80d92c$1@news.povray.org>...
> > Tor Olav Kristensen wrote in message <3B7DC4F1.C18AF6E3@hotmail.com>...
> > > Can anyone tell me if it is at all
> > > possible to extract a fifth component
> > > from a 5D-color vector in POV ?
> > > (This would be useful for 5D-macros.)
> >
> > #local V=<1,2,3,4,5>;
> > #warning concat(str(V.filter,0,-1),"\n")
> 
> sorry I forgot:
> a) it works in megapov 0.6a - I think there is bug in POV 3.1
> b) add #warning concat(str(V.transmit,0,-1),"\n")

Thank you very much Wlodzimierz !

I haven't been able to find those
dot-filter and dot-transmit operators
in the manual. I guess I've been 
looking in the wrong places...

Is there a difference between .t and
.transmit operators ? I.e.: Are they 
both referencing the fifth element ?

I have used the .t operator in my code
to extract a fourth element. I suspected
there to be a .f operator also, but that
didn't seem to be the case though.


Tor Olav


Post a reply to this message

From: Ron Parker
Subject: Re: About determinands and n-dimensional cross products
Date: 21 Aug 2001 00:26:41
Message: <slrn9o3oo5.h14.ron.parker@fwi.com>
On Tue, 21 Aug 2001 00:22:08 +0200, Tor Olav Kristensen wrote:
>Is there a difference between .t and
>.transmit operators ? I.e.: Are they 
>both referencing the fifth element ?

.t is a MegaPOV-only thing, along with .s.  As far as I know, they're
totally unimplemented, so any results you might get with them are purest
happenstance.  They have nothing to do with transmit and filter; I think
they were supposed to be some sort of texture-space coordinates for one
of the spline-patch things in original isosurface patch by R. Suzuki et al.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

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