## matrix and polygon (or vertex) normals

### 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

### matrix and polygon (or vertex) normals

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.

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