![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Warp wrote:
> clipka <ano### [at] anonymous org> wrote:
>> Isn't such a transformation non-affine? So it wouldn't be possible to do
>> it with a simple 4x4 matrix multiplication.
The trick which allows this is to use "homogeneous coordinates".
Basically the 4th (or 3rd in you're in 2D) index in the coordinate
vector is treated differently and is used to divide the other
coordinates. For example, let's say that the camera matrix maps a point
(x,y,z,1) in 3D homogeneous coordinates to the point (u,v,w) in camera
viewing coordinates. The actual position on the "screen" given by this
is then (u/w, v/w), where we've divided by the last coordinate. It's
this division which allows non-affine transformations to be represented.
Wikipedia has a nice article on homogeneous coordinates if you're
interested in more:
http://en.wikipedia.org/wiki/Homogeneous_coordinates
http://en.wikipedia.org/wiki/Camera_matrix
> Multiplication with a 4x4 matrix can be used for perspective projection.
> It's a 3x3 transformation matrix which is restricted to affine transformations.
3x4 is restricted to affine transformations. A 3x3 matrix is restricted
to linear transformations (assuming Cartesian instead of homogeneous
coordinates).
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Sat, 13 Feb 2010 21:05:06 +0100, Warp <war### [at] tag povray org> wrote:
> Hence the near and far clipping planes could indeed be "encoded" into the
> transformation matrix by specifying the depth scaling (which, I suppose,
> would prove my original assertion in this thread wrong).
>
> However, I don't remember if something else was involved for this to
> work properly.
The clipping itself becomes slightly more complicated in that it must be
performed in homogenous coordinates.
--
FE
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> On Sat, 13 Feb 2010 21:05:06 +0100, Warp <war### [at] tag povray org> wrote:
> > Hence the near and far clipping planes could indeed be "encoded" into the
> > transformation matrix by specifying the depth scaling (which, I suppose,
> > would prove my original assertion in this thread wrong).
> >
> > However, I don't remember if something else was involved for this to
> > work properly.
> The clipping itself becomes slightly more complicated in that it must be
> performed in homogenous coordinates.
Ah, yes, homogenous coordinates. It starts ringing bells now. That's the
thing I was not remembering in all this. (Man, it has been a long time since
I knew all these things.)
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Warp wrote:
> point coordinates will overflow, screwing up the projected coordinates, which
I hadn't thought of that. Thanks for clearing it up.
> Note that I don't have first-hand experience on this.
Well, looking at the structure, I'm pretty sure it's not in the matrix, but
again I wanted to make sure it wasn't something clever, as you said.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson wrote:
> Typically, the perspective transform is defined such that the resulting
> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then
> be performed without knowledge about the original clipping planes.
I see. So there's extra information, but it might be implicit. Interesting
approach.
Now I'm curious enough to screw around with the matrixes and math again to
see if I can figure out what it's doing.
(I'll also mention in passing that the XNA compiler is the first compiler
I've run into that hoists constant expressions in loops not only out of the
loop but onto an entirely different CPU altogether. :-)
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Warp" <war### [at] tag povray org> wrote in message
news:4b770ead@news.povray.org...
> clipka <ano### [at] anonymous org> wrote:
> > Isn't such a transformation non-affine? So it wouldn't be possible to do
> > it with a simple 4x4 matrix multiplication.
> Multiplication with a 4x4 matrix can be used for perspective projection.
> It's a 3x3 transformation matrix which is restricted to affine
transformations.
>
> (Yes, I didn't know that either, many years ago.)
That's not correct. 3x3 matrix multiplication only gives you linear
transformations (in 3D). You need a particularly designed 4x4 matrix for
affine transformations, which includes translation on top of linear
transformations of scaling, rotation and projective ("orthogonal")
transformations. Perspective projection is not strictly achieved with matrix
multiplication applied to standard coordinates, so you include a special
equivalency clause / homogenous coordinates (a division in disguise), and
with that in mind, you can use the remaining elements of the 4x4 matrix to
that end.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
somebody <x### [at] y com> wrote:
> Perspective projection is not strictly achieved with matrix
> multiplication applied to standard coordinates, so you include a special
> equivalency clause / homogenous coordinates (a division in disguise), and
> with that in mind, you can use the remaining elements of the 4x4 matrix to
> that end.
Yeah, perspective projection with a 4x4 transformation matrix is only
possible if the points are in homogeneous coordinates.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson wrote:
> Typically, the perspective transform is defined such that the resulting
> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then
> be performed without knowledge about the original clipping planes.
Just peeking at some of the HLSL values that get passed around and some of
the graphics card assembler instructions, it looks like this is quite
likely. For example, there's a "free" modifier you can use to shift a result
from [-1...1] to [0...1] on the graphics card without taking any more
instruction cycles. Textures seem to get 0...1 while visible X,Y coordinates
seem to go -1...1. I'm not sure which range the Z coordinates fall into,
but it certainly seems reasonable to believe that if the X and Y are scaled
in such a way, the Z likely will be also.
--
Darren New, San Diego CA, USA (PST)
Forget "focus follows mouse." When do
I get "focus follows gaze"?
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>> Typically, the perspective transform is defined such that the resulting
>> z-coordinates fall in a suitable range (e.g. [0,1]). Clipping can then be
>> performed without knowledge about the original clipping planes.
>
> I see. So there's extra information, but it might be implicit. Interesting
> approach.
Yes, the 3D hardware is usually programmed to clip when Z is outside a
certain range. It is then up to you (the programmer) to decide how you map
real world coordinates to this range, and yes you can do it with just a 4x4
matrix.
DirectX has a helper function to create such a matrix for you:
http://tinyurl.com/yg5z9t7
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |