POV-Ray : Newsgroups : povray.pov4.discussion.general : superlinear transformations Server Time 5 Dec 2023 23:08:09 EST (-0500)
 superlinear transformations (Message 1 to 9 of 9)
 From: Dan Connelly Subject: superlinear transformations Date: 26 Sep 2008 14:03:57 Message: <48dd240d\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48dd240d%241%40news.povray.org",
"dateCreated": "2008-09-26T18:03:57+00:00",
"datePublished": "2008-09-26T18:03:57+00:00",
"author": {
"@type": "Person",
"name": "Dan Connelly"
}
}
Presently, objects can be transformed according to a displacement vector plus a 3x3
matrix.  This is a linear transformation.  However, it would be useful if one could
also do nonlinear transformations.   For example, x -> x * y, or x -> x * (1 + 0.1 *
sin(y)).  I can easily see how this would become hopelessly complex, but it would be
useful.
```
 From: Warp Subject: Re: superlinear transformations Date: 26 Sep 2008 14:58:58 Message: <48dd30f2@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48dd30f2%40news.povray.org",
"dateCreated": "2008-09-26T18:58:58+00:00",
"datePublished": "2008-09-26T18:58:58+00:00",
"author": {
"@type": "Person",
"name": "Warp"
}
}
Dan Connelly <djc### [at] yahoocom> wrote:
> Presently, objects can be transformed according to a displacement
> vector plus a 3x3 matrix.  This is a linear transformation.  However,
> it would be useful if one could also do nonlinear transformations.
> For example, x -> x * y, or x -> x * (1 + 0.1 * sin(y)).  I can easily
> see how this would become hopelessly complex, but it would be useful.

Actually objects are not transformed at all. That would be impossible
in the generic case.

What POV-Ray does is a common raytracing trick: Rather than transform
the object with the transformation matrix, it transforms the ray with
the inverse of the transformation matrix. The end result is exactly the
same, but the advantage is that it's much easier (and in many cases,
*possible*) to do it like this.

This is the reason why transformations must be linear. The straight ray
must be straight also after it's transformed. It cannot become curved.
This is the reason why only rotation, scaling, skewing (which is actually
a combination of rotation and uneven scaling) and translation is possible.

Raytracing with curved lines cannot be done accurately, and would be
extremely slow.

--
- Warp
```
 From: Dan Connelly Subject: Re: superlinear transformations Date: 26 Sep 2008 20:46:33 Message: <48dd8269\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48dd8269%241%40news.povray.org",
"dateCreated": "2008-09-27T00:46:33+00:00",
"datePublished": "2008-09-27T00:46:33+00:00",
"author": {
"@type": "Person",
"name": "Dan Connelly"
}
}
Warp wrote:
> Dan Connelly <djc### [at] yahoocom> wrote:
>> Presently, objects can be transformed according to a displacement
>> vector plus a 3x3 matrix.  This is a linear transformation.  However,
>> it would be useful if one could also do nonlinear transformations.
>> For example, x -> x * y, or x -> x * (1 + 0.1 * sin(y)).  I can easily
>> see how this would become hopelessly complex, but it would be useful.
>
>   Actually objects are not transformed at all. That would be impossible
> in the generic case.
>
>   What POV-Ray does is a common raytracing trick: Rather than transform
> the object with the transformation matrix, it transforms the ray with
> the inverse of the transformation matrix. The end result is exactly the
> same, but the advantage is that it's much easier (and in many cases,
> *possible*) to do it like this.
>
>   This is the reason why transformations must be linear. The straight ray
> must be straight also after it's transformed. It cannot become curved.
> This is the reason why only rotation, scaling, skewing (which is actually
> a combination of rotation and uneven scaling) and translation is possible.
>
>   Raytracing with curved lines cannot be done accurately, and would be
> extremely slow.
>

I'm a bit confused about the skew argument.  There's

matrix:

3 degrees of freedom: transformation
3 degrees of freedom: scaling
3 degrees of freedom: rotation

So this leaves 3 more degrees of freedom..... which are skew.

(right-hand coordinates)

| ax  0  0 |
| 0  ay  0 | : scaling
| 0  0  az |

| cz  sz  0 |

| 0   0   1 |   (permute for x, y)

So between scaling and rotation, I'm constrained to
antisymmetric matrixes.

A typical shear matrix:

| uz  vz  0 |

| 0   0   1 |   (permute for x, y)

So this gives me 9 parameters:
ax, ay, az, sx, sy, sz, vx, vy, vz

the same number of parameters needed to specify the full matrix.
```
 From: Dan Connelly Subject: Re: superlinear transformations Date: 27 Sep 2008 00:40:41 Message: <48ddb949\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48ddb949%241%40news.povray.org",
"dateCreated": "2008-09-27T04:40:41+00:00",
"datePublished": "2008-09-27T04:40:41+00:00",
"author": {
"@type": "Person",
"name": "Dan Connelly"
}
}
Dan Connelly wrote:
> Warp wrote:
>> This is the reason why only rotation, scaling, skewing (which is actually
>> a combination of rotation and uneven scaling) and translation is
>> possible.
>>

> I'm a bit confused about the skew argument.  There's

> matrix:
>
> 3 degrees of freedom: transformation

That should be translation.

> 3 degrees of freedom: scaling
> 3 degrees of freedom: rotation
>
> So this leaves 3 more degrees of freedom..... which are skew.
>

> (right-hand coordinates)
>
> | ax  0  0 |
> | 0  ay  0 | : scaling
> | 0  0  az |
>
> | cz  sz  0 |

> | 0   0   1 |   (permute for x, y)
>
> So between scaling and rotation, I'm constrained to
> antisymmetric matrixes.
>
> A typical shear matrix:
>
> | uz  vz  0 |

> | 0   0   1 |   (permute for x, y)
>
> So this gives me 9 parameters:
> ax, ay, az, sx, sy, sz, vx, vy, vz
>
> the same number of parameters needed to specify the full matrix.
>

Matrix multiplication fails to preserve symmetry, only addition.
So given that, it's possible to generate a symmetric component (the
offdiagonal terms generating shear) in addition to a antisymmetric
component (the off-diagonal terms generating rotation) from rotation
and scaling together, as long as the scaling is non-uniform, as Warp
said.  My linear algebra is too rusty....

| 0 1 | |-1 0 |       | 0 1 |
|-1 0 | | 0 1 |   =   | 1 0 |

And my degrees of freedom argument follows only if one is allowed a single
rotation and a single scaling.  But generating pure shear requires two rotations.

Sorry....

Dan
```
 From: Le Forgeron Subject: Re: superlinear transformations Date: 27 Sep 2008 04:02:44 Message: <48dde8a4\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48dde8a4%241%40news.povray.org",
"dateCreated": "2008-09-27T08:02:44+00:00",
"datePublished": "2008-09-27T08:02:44+00:00",
"author": {
"@type": "Person",
"name": "Le Forgeron"
}
}
Le Fri, 26 Sep 2008 21:40:57 -0700, Dan Connelly a modifié des petits
morceaux de l'univers pour nous faire lire :

> And my degrees of freedom argument follows only if one is allowed a
> single rotation and a single scaling.  But generating pure shear
> requires two rotations.
>
> Sorry....
>
> Dan

Might I remind people that the internal transformation matrix is a 4x4,
using weighted coordinates system (x,y,z,w).
Successive transformations are stacked together by matrix-multiplication
at parse time.

Now, I would be interested in seeing a screwing transformation-matrix...
```
 From: Warp Subject: Re: superlinear transformations Date: 27 Sep 2008 05:13:19 Message: <48ddf92f@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#48ddf92f%40news.povray.org",
"dateCreated": "2008-09-27T09:13:19+00:00",
"datePublished": "2008-09-27T09:13:19+00:00",
"author": {
"@type": "Person",
"name": "Warp"
}
}
Le Forgeron <jgr### [at] freefr> wrote:
> Now, I would be interested in seeing a screwing transformation-matrix...

http://www.geocities.com/evilsnack/matrix.htm

--
- Warp
```
 From: Nicolas Alvarez Subject: Re: superlinear transformations Date: 23 Nov 2008 18:10:40 Message: <4929e2f0@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#4929e2f0%40news.povray.org",
"dateCreated": "2008-11-23T23:10:40+00:00",
"datePublished": "2008-11-23T23:10:40+00:00",
"author": {
"@type": "Person",
"name": "Nicolas Alvarez"
}
}
Warp wrote:
>   This is the reason why transformations must be linear. The straight ray
> must be straight also after it's transformed. It cannot become curved.
> This is the reason why only rotation, scaling, skewing (which is actually
> a combination of rotation and uneven scaling) and translation is possible.

Hmm I don't think nonlinear transformations would cause the ray to be a
curve. Non-linear transf. are already possible in isosurfaces.

All you need is a different matrix for each pixel. Or rather, instead of
using a matrix you multiply with, use a generic function.
```
 From: scott Subject: Re: superlinear transformations Date: 24 Nov 2008 04:42:58 Message: <492a7722\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#492a7722%241%40news.povray.org",
"dateCreated": "2008-11-24T09:42:58+00:00",
"datePublished": "2008-11-24T09:42:58+00:00",
"author": {
"@type": "Person",
"name": "scott"
}
}
> Hmm I don't think nonlinear transformations would cause the ray to be a
> curve.

Of course they would, if I apply the following transformation to a sphere:

x -> x
y -> y^3
z -> z

Then it's impossible to convert this to a "straight ray intersecting with a
unit sphere at the origin" problem, which is what POV does for all linear
transformations.

> Non-linear transf. are already possible in isosurfaces.

Yes, and they are much slower than rendering primitives like a sphere and
take setting up to get correct results.  Primitives just work, fast.
```
 From: Warp Subject: Re: superlinear transformations Date: 24 Nov 2008 12:06:01 Message: <492adef9@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"dateCreated": "2008-11-24T17:06:01+00:00",
"datePublished": "2008-11-24T17:06:01+00:00",
"author": {
"@type": "Person",
"name": "Warp"
}
}
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Hmm I don't think nonlinear transformations would cause the ray to be a
> curve.

Well, the very definition of "non-linear transformation" *is* that
straight lines don't necessarily remain straight after the transformation.

Conversely the very definition of "linear transformation" is that any
straight line remains straight after the transformation.

> Non-linear transf. are already possible in isosurfaces.

In the same sense as non-linear transformations are "possible" for
triangle meshes (although not really, but almost).

You are not really transforming the isosurface object. You are modifying
its function, which is a different thing (from the point of view of
raytracing). You can't do that for other primitives.

> All you need is a different matrix for each pixel. Or rather, instead of
> using a matrix you multiply with, use a generic function.

Simply changing the direction of the ray according to a function, while
keeping the ray straight, is *not* enough to achieve non-linear
transformations of objects.

--
- Warp
```