matrix and polygon (or vertex) normals

matrix and polygon (or vertex) normals

Post by Lucas Monte » Mon, 30 Jun 2003 19:21:03



hello,

i'm doing a basic 3d modeler with a perspective view. i'd like to know
how i can adapt the perspective transformation matrix for normals, or if
it simply doesn't need to be adapted?

the formulas for perspective transformation are (when vertex are in the
eye space with the camera oriented along the x axis) :

xs = F * ((1 - D) / xe) / (F - D)

ys = D * ye / (h * xe)

zs = D * ze / (h * xe)

with D is the distance between the eye and the view plane, F is the
distance of the far clipping plane, and h the dimension of the view plane.

to transform into matrix form we separate like this :

xc = (h * F *  xe) / (D * (F - D)  -  (h * F) / (F - D)

yc = ye

zc = ze

w = (h * xe) / D

and then xs = xc / w ,  ys = xc / w   and   zs = zc / w

this gives the matrix :

| (hF) / (D(F-D)   0     0     (-hF) / (F - D) |
|       0          1     0             0       |
|       0          0     1             0       |
|      h/d         0     0             0       |

so the thing i'd like to know is how to obtain the equivalent matrix for
normals ?

i'v heard that it can be done by deleting the translations elements
(M30, M31 and M32), and then getting the transpose of the inverse of the
matrix M. but as i'm not sure of that i'd like different opinion.

Thanks,

--
Lucas
Montes

 
 
 

matrix and polygon (or vertex) normals

Post by Hans-Bernhard Broeke » Tue, 01 Jul 2003 02:28:40



Quote:> hello,
> i'm doing a basic 3d modeler with a perspective view. i'd like to know
> how i can adapt the perspective transformation matrix for normals, or if
> it simply doesn't need to be adapted?

Depends on what your matrix does.  The true story is that normals
transform like "dual vectors".  I.e. if you transform vectors by a
matrix M, normals get transformed by inverse(transpose(M)).

For pure rotations with determinant +1 (no mirroring), that results in
M itself, again.

Quote:> i'v heard that it can be done by deleting the translations elements
> (M30, M31 and M32), and then getting the transpose of the inverse of the
> matrix M. but as i'm not sure of that i'd like different opinion.

You don't have to delete any elements.  Just make sure your normals,
just like your vectors, have 4 coordinates, the fourth one being zero.
As a benefit, this will let you transform whole plane equations, not
just normal vectors.
--

Even if all the snow were burnt, ashes would remain.

 
 
 

1. matrix and polygon (or vertex) normals

hello,

i'm doing a basic 3d modeler with a perspective view. i'd like to know
how i can adapt the perspective transformation matrix for normals, or if
it simply doesn't need to be adapted?

the formulas for perspective transformation are (when vertex are in the
eye space with the camera oriented along the x axis) :

xs = F * ((1 - D) / xe) / (F - D)

ys = D * ye / (h * xe)

zs = D * ze / (h * xe)

with D is the distance between the eye and the view plane, F is the
distance of the far clipping plane, and h the dimension of the view plane.

to transform into matrix form we separate like this :

xc = (h * F *  xe) / (D * (F - D)  -  (h * F) / (F - D)

yc = ye

zc = ze

w = (h * xe) / D

and then xs = xc / w ,  ys = xc / w   and   zs = zc / w

this gives the matrix :

| (hF) / (D(F-D)   0     0     (-hF) / (F - D) |
|       0          1     0             0       |
|       0          0     1             0       |
|      h/d         0     0             0       |

so the thing i'd like to know is how to obtain the equivalent matrix for
normals ?

i'v heard that it can be done by deleting the translations elements
(M30, M31 and M32), and then getting the transpose of the inverse of the
matrix M. but as i'm not sure of that i'd like different opinion.

Thanks,

--
Lucas
Montes

2. Needs Advice...

3. Polygon Vertex Normals

4. mapping a quadrilateral to a square

5. Normals for polygons containing more than 3 vertices

6. CO-Denver- Visual Basic Developer ( 469972 )

7. Glassner's Algorithm: Building Vertex Normals from an Unstructured Polygon List

8. clean cache

9. BSP polygon splitting and vertex normals

10. triangles with per face normals SLOWER than per vertex normals

11. Vertex normals at the Bezier control vertex

12. Xform vertexes of a primitive by different matrixes / VERTEX BLENDING

13. question: vertex arrays under win98 + vertices to polygons