Monday, May 9, 2011

Mirroring a point on a 3D plane


Context

Consider the plane in three dimensional space defined by a point and a normal vector :


Mirroring a point

Mirroring a point with this plane is very straightforward.We calculate the distance from the point to the plane (covered in plane equation in 3D ) and then we use this distance and the calculated normal toget the point pm

.

The formula for pm is :

Important : this formula only works if the normal is a unit vector.

Matrix form

In a 3D application the mirror operation is used to calculate planar reflections (ordinary mirrors or the surface of a lake). To plug the mirror operation into the application it is necessary to represent the mirror operation as a matrix :

p

origin of the

plane , a const

ant

p1

point to mirror

pm

result of the mirror operation


We start from the original equation :

OpenGL matrix form

OpenGL stores matrices in column major order and the matrix is simply formed by extracting p1x, p1y and p1zfrom the equations :

DirectX matrix form

DirectX stores matrices in row major order and the matrix is the transpose (switch columns and rows) of the OpenGLmatrix form :

Posted by: Garo Makassian

5 comments:

  1. In OpenGL, a 3D point in eye space is projected onto the near plane (projection plane). The following diagrams shows how a point (x, y, z) in eye space is projected to (xp, yp, zp) on the near plane.

    ReplyDelete
  2. I liked how linear algebra is applied. Nice post.

    ReplyDelete
  3. It is interesting how you can create a mirror image in three-dimensional space using matrix form. I think it can be simply done using AutoCad program for civil engineers! Mniha Garo Hala Madrid :)!

    ReplyDelete
  4. This aroused my curiosity to know more about Matrices and how they can be used in real life. This post is an interesting one. But i still believe that this is just the beginning of Matrices.
    Hala Madrid

    ReplyDelete
  5. Excellent post Garo!!!!!!!
    Thanks!

    ReplyDelete