logo back up home forward   further reading more topics »

Maths - Reflection using Matrix

Matrix representation

normal component

Norm = Va P = (Va × P) * P/|P|²

This is derived on this page.

parallel component

Proj = Va || P = Va • P * P/|P|²

This is derived on this page.

Reflection matrix

Given the inversion I'll add the terms instead of subtracting them to give the reflection result:

p → 1 /
(Px² + Py² + Pz²)*
-Px² + Pz²+ Py² - 2 * Px * Py - 2 * Px * Pz
- 2 * Py * Px -Py² + Px² + Pz² - 2 * Py * Pz
- 2 * Pz * Px -2 * Pz * Py -Pz² + Py² + Px²
[p]

Note that this matrix is symmetrical about the leading diagonal, unlike the rotation matrix, which is the sum of a symmetric and skew symmetric part.

Simple cases

In order to check the above lets take the simple cases where the point is reflected in the various axis:

Reflection in yz

-1 0 0
0 1 0
0 0 1

Reflection in xz

1 0 0
0 -1 0
0 0 1

Reflection in xy

1 0 0
0 1 0
0 0 -1

Determinant and eigen values

Another check is that the determinant of reflection matrix is -1

Example

refection in 30° line

As an example we want to reflect the point (1,0,0) in a plane at 30 degrees.

P2 =
-Px² + Pz² + Py² - 2 * Px * Py - 2 * Px * Pz
- 2 * Py * Px -Py² + Px² + Pz² - 2 * Py * Pz
- 2 * Pz * Px -2 * Pz * Py -Pz² + Py² + Px²
[P1]

where Px,Py,Pz is the normal to the mirror which is: (-0.5,0.866,0)

and P1 is the initial point which is (1,0,0)

substituting these values gives:

P2 =
-0.25 + 0 + 0.75 - 2 * -0.433 0
- 2 * -0.433 -0.75 + 0.25 + 0 0
0 0 0 + 0.75 + 0.25

 

1
0
0

 

P2 =
0.5 0.866 0
0.866 -0.5 0
0 0 1

 

1
0
0

 

multiplying to vector by the matrix gives:

P2 =

 

0.5
0.866
0

 

 


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

flag flag flag flag flag flag Clifford Algebra to Geometric Calculus: A Unified Language for Mathematics and Physics (Fundamental Theories of Physics). This book is intended for mathematicians and physicists rather than programmers, it is very theoretical. It covers the algebra and calculus of multivectors of any dimension and is not specific to 3D modelling.

 

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2010 Martin John Baker - All rights reserved - privacy policy.