POV-Ray : Newsgroups : povray.off-topic : More math fail Server Time
4 Sep 2024 15:16:39 EDT (-0400)
  More math fail (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Orchid XP v8
Subject: More math fail
Date: 17 Jan 2010 15:42:00
Message: <4b537618$1@news.povray.org>
All these years, I thought the correct way to compute the cross product 
of two vectors is

   x3 = y1 z2 - z1 y2
   y3 = x1 z2 - z1 x2
   z3 = x1 y2 - y1 x2

But, apparently, I was wrong. The correct way is in fact

   x3 = y1 z2 - z1 y2
   y3 = z1 x2 - x1 z2
   z3 = x1 y2 - y1 x2

In particular, this results in y3 having the opposite sign. No wonder my 
program can't construct an orthogonal vector basis! >_<

FAIL.

The best part? I got this wrong in a library I released. Yes, my program 
is failing due to a bug in my own damned library... :'{

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: andrel
Subject: Re: More math fail
Date: 17 Jan 2010 16:33:17
Message: <4B53821D.2090000@hotmail.com>
On 17-1-2010 21:42, Orchid XP v8 wrote:
> All these years, I thought the correct way to compute the cross product 
> of two vectors is
> 
>   x3 = y1 z2 - z1 y2
>   y3 = x1 z2 - z1 x2
>   z3 = x1 y2 - y1 x2
> 
> But, apparently, I was wrong. The correct way is in fact
> 
>   x3 = y1 z2 - z1 y2
>   y3 = z1 x2 - x1 z2
>   z3 = x1 y2 - y1 x2
> 

You should have caught that based on symmetry.


Post a reply to this message

From: Invisible
Subject: Re: More math fail
Date: 18 Jan 2010 04:49:36
Message: <4b542eb0@news.povray.org>
>> All these years, I thought the correct way to compute the cross 
>> product of two vectors is
>>
>>   x3 = y1 z2 - z1 y2
>>   y3 = x1 z2 - z1 x2
>>   z3 = x1 y2 - y1 x2
>>
>> But, apparently, I was wrong. The correct way is in fact
>>
>>   x3 = y1 z2 - z1 y2
>>   y3 = z1 x2 - x1 z2
>>   z3 = x1 y2 - y1 x2
>>
> 
> You should have caught that based on symmetry.

Well, the rule seems clear: the expression for (say) Y involves every 
coordinate except Y itself. I never realised it actually matters which 
order you put them in...


Post a reply to this message

From: scott
Subject: Re: More math fail
Date: 18 Jan 2010 05:11:59
Message: <4b5433ef$1@news.povray.org>
> Well, the rule seems clear: the expression for (say) Y involves every 
> coordinate except Y itself. I never realised it actually matters which 
> order you put them in...

Your initial algorithm would fail even the most basic test of the cross 
product:

x cross y = z
y cross z = x
z cross x = y

where x = (1,0,0), y = (0,1,0), z = (0,0,1)


Post a reply to this message

From: Le Forgeron
Subject: Re: More math fail
Date: 18 Jan 2010 05:13:51
Message: <4b54345f$1@news.povray.org>
Invisible a écrit :
>>> All these years, I thought the correct way to compute the cross
>>> product of two vectors is
>>>
>>>   x3 = y1 z2 - z1 y2
>>>   y3 = x1 z2 - z1 x2
>>>   z3 = x1 y2 - y1 x2
>>>
>>> But, apparently, I was wrong. The correct way is in fact
>>>
>>>   x3 = y1 z2 - z1 y2
>>>   y3 = z1 x2 - x1 z2
>>>   z3 = x1 y2 - y1 x2
>>>
>>
>> You should have caught that based on symmetry.
> 
> Well, the rule seems clear: the expression for (say) Y involves every
> coordinate except Y itself. I never realised it actually matters which
> order you put them in...

My rule is rather a rotation (X->Y->Z->X) and yes, order matter.
You can write the first line as you want, but for the next lines, the
rotation must be applied on it strictly.

Basic check: X.Y gives Z, Y.Z gives X, Z.X gives Y, it's always a XYZ
sequence in loop. (X Y Z X Y Z...)

-- 
Real software engineers work from 9 to 5, because that is<br/>
the way the job is described in the formal spec.  Working<br/>
late would feel like using an undocumented external procedure.


Post a reply to this message

From: Invisible
Subject: Re: More math fail
Date: 18 Jan 2010 05:38:03
Message: <4b543a0b$3@news.povray.org>
>> Well, the rule seems clear: the expression for (say) Y involves every
>> coordinate except Y itself. I never realised it actually matters which
>> order you put them in...
> 
> My rule is rather a rotation (X->Y->Z->X) and yes, order matter.

Yes, that does appear to be the correct method...


Post a reply to this message

From: Neeum Zawan
Subject: Re: More math fail
Date: 21 Jan 2010 18:35:33
Message: <4b58e4c5$1@news.povray.org>
On 01/17/10 12:42, Orchid XP v8 wrote:
> All these years, I thought the correct way to compute the cross product
> of two vectors is
>
> x3 = y1 z2 - z1 y2
> y3 = x1 z2 - z1 x2
> z3 = x1 y2 - y1 x2

Oh dear. Use the determinant form - easiest to remember:

http://en.wikipedia.org/wiki/Cross_product#Matrix_notation

-- 
I'm addicted to placebos. I'd give them up, but it wouldn't make any 
difference. - Steven Wright


Post a reply to this message

From: Invisible
Subject: Re: More math fail
Date: 22 Jan 2010 04:33:56
Message: <4b597104$1@news.povray.org>
Neeum Zawan wrote:

> Oh dear. Use the determinant form - easiest to remember:
> 
> http://en.wikipedia.org/wiki/Cross_product#Matrix_notation

...except that then I'd have to somehow remember the correct way to do 
matrix multiplication. (Something which I never get right with more than 
50% probability...)


Post a reply to this message

From: Warp
Subject: Re: More math fail
Date: 22 Jan 2010 04:35:51
Message: <4b597177@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Neeum Zawan wrote:

> > Oh dear. Use the determinant form - easiest to remember:
> > 
> > http://en.wikipedia.org/wiki/Cross_product#Matrix_notation

> ...except that then I'd have to somehow remember the correct way to do 
> matrix multiplication. (Something which I never get right with more than 
> 50% probability...)

  Then you just end up using left-handed coordinates for your cross product
rather than right-handed. In other words, it only affects the sign of the
result.

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: More math fail
Date: 22 Jan 2010 04:45:47
Message: <4b5973cb$1@news.povray.org>
>> ...except that then I'd have to somehow remember the correct way to do 
>> matrix multiplication. (Something which I never get right with more than 
>> 50% probability...)
> 
>   Then you just end up using left-handed coordinates for your cross product
> rather than right-handed. In other words, it only affects the sign of the
> result.

Oh, does it?

With general matrix multiplication, getting it wrong tends to really 
mess things up. But in the specific case of a cross product, maybe it 
doesn't...


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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