POV-Ray : Newsgroups : povray.advanced-users : Tough math help needed Server Time
29 Jul 2024 18:20:40 EDT (-0400)
  Tough math help needed (Message 1 to 4 of 4)  
From: Peter Popov
Subject: Tough math help needed
Date: 27 Aug 2001 16:13:14
Message: <sn9lotkt2skm94gunq0g6gm8rch2f8oq9r@4ax.com>
I have a tough problem to solve and I am really stuck. I hope some of
the more math-talented people here can help me.

It's a XYZ -> UVW transformation function that I want to find the
inverse of. Let's first take a look at the simpler case, XY -> UV.

Take a unit square and a point P in it with coordinates a, b. These
are the XY coordinates. Now take four random points in space.
Supposing they are not coplanar, there's a unique second-order
function passing through them known as the 'saddle' function. It is
actually a hyperbolic function.

The hyperbolloid is the only second-order function that has two sets
of rulings. Each ruler of one set intersects all rulers of the other
and vice versa. Also, no two rulers of one set intersect. This means
that at each point on the surface, exactly one ruler of one set and
one of the other are present, which makes them a perfect choice for UV
coordinates.

Let's go back to the four arbitrary points in space I mentioned, let's
call them A, B, C and D (ASCII art follows, use a fixed-width font)

 D-----C
/     /
A    /
 \_B/

AB and DC belong to one set of rulers, [1] and AD and BC belong to the
other, [2]. Now, if we take two points on AB and DC, M and N resp., so
that the AM:AB = DN:DC, the line MN will belong to [1] and will have a
U coordinate of exactly that ratio. Let's choose M and N so that that
ratio is a. The point P' on MN for which MP':MN = b then has UV
coordinates a and b (directly follows from the above). Let's find its
XY coordinates:

(note: everything is vectors, i.e. AB = B - A, except a and b)

AM = a*AB
DN = a*DC
MN = AN - AM = AD + DN - AM
MP' = b*MN = b*(AD + DN - AM) = b*(AD + a*DC - a*AB) =
    = b*(AD + a*(DC - AB))
AP' = AM + MP' = a*AC + b*(AD + a*(DC - AB))
P' = A + AP' = A + a*AC + b*(AD + a*(DC - AB))

OK, this was the easy part :)

Now, knowing A, B, C, D and P', how do I find a and b (or P, it's the
same)?


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Alberto
Subject: Re: Tough math help needed
Date: 27 Aug 2001 20:36:09
Message: <3B8AE6F7.21E0D2B7@usb.ve>
Peter Popov wrote:
> 
> ... 
>  D-----C
> /     /
> A    /
>  \_B/
> 
> AB and DC belong to one set of rulers, [1] and AD and BC belong to the
> other, [2]. Now, if we take two points on AB and DC, M and N resp., so
> that the AM:AB = DN:DC, the line MN will belong to [1] and will have a
> U coordinate of exactly that ratio. Let's choose M and N so that that
> ratio is a. The point P' on MN for which MP':MN = b then has UV
> coordinates a and b (directly follows from the above). Let's find its
> XY coordinates:
> 
> (note: everything is vectors, i.e. AB = B - A, except a and b)
> 
> AM = a*AB
> DN = a*DC
> MN = AN - AM = AD + DN - AM
> MP' = b*MN = b*(AD + DN - AM) = b*(AD + a*DC - a*AB) =
>     = b*(AD + a*(DC - AB))
> AP' = AM + MP' = a*AC + b*(AD + a*(DC - AB))
> P' = A + AP' = A + a*AC + b*(AD + a*(DC - AB))
> 
> OK, this was the easy part :)
> 
> Now, knowing A, B, C, D and P', how do I find a and b (or P, it's the
> same)?

In your last equation, a and b are the unknowns. Take the inner product
of this equation with say, AB. You will end with  a scalar equation.
Take the inner product of your last equation with AD and you'll get a
second equation. Now you have a pair of equations with two unkowns. This
system should be soluble.

Alberto.


Post a reply to this message

From: Peter Popov
Subject: Re: Tough math help needed
Date: 28 Aug 2001 08:19:31
Message: <na2noto1asemvpn2jqd0o3n4141k55h4u3@4ax.com>
On Mon, 27 Aug 2001 20:34:00 -0400, Alberto <jac### [at] usbve> wrote:

>In your last equation, a and b are the unknowns. Take the inner product
>of this equation with say, AB. You will end with  a scalar equation.
>Take the inner product of your last equation with AD and you'll get a
>second equation. Now you have a pair of equations with two unkowns. This
>system should be soluble.

I can also split the last equation into two, one for the x components
of vectors and one for the y components which is the same as you
suggest, only the unit vectors i and j are used for multipliers
instead of AB and AD. The problem with this approach is that the
system is non-linear due to the term a*b. When extending this
transformation to three dimensions, I get a system of three
third-order equations which, although it has only one set of roots in
the range [0; 1] is too hard for me to solve.

I can describe the UVW transform but I'd rather have this one solved
before the more complex one is tackled.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Alberto
Subject: Re: Tough math help needed
Date: 28 Aug 2001 12:38:55
Message: <3B8BC895.55B983AA@usb.ve>
> Peter Popov wrote:
> 
> I can also split the last equation into two, one for the x components
> of vectors and one for the y components which is the same as you
> suggest, only the unit vectors i and j are used for multipliers
> instead of AB and AD.

In principle you can do that. The problem is that there are chances that taking
the inner product with say, i can lead to the equation 0 = 0. In the exposition
you made it is clear that it's better to choose AB and AD as the projecting vectors.

> The problem with this approach is that the
> system is non-linear due to the term a*b.

This problem is unavoidable. It's related to the fact that you're using second
order equations. One thing you can do is to use a vector which is orthogonal to
DC - AB. The inner product of your last equation with such a vector will lead to
an equation which is linear in a and b. In this way you'll need to solve only
one second order equation. I have the impression that only one of the roots will
be meaningful for example being a positive number between 0 and 1. The other
root being out of this range.

> When extending this
> transformation to three dimensions, I get a system of three
> third-order equations which, although it has only one set of roots in
> the range [0; 1] is too hard for me to solve.
> 
> I can describe the UVW transform but I'd rather have this one solved
> before the more complex one is tackled.
> 
Hmm. The problem here is more complex. There are chances that you can construct
a system of three equations in which only one is of third order. I think you'll
have to set up numerical a method to solve the cubic equation. In this case the
hope is that only one of the roots will be real, the other two being complex (a
b and c? should be unique).

I understand that this is of little help but this are my thoughts.

Alberto.


Post a reply to this message

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