reflections

Functions to work with reflections

Terms used in function names:

  • mat : array shape (3, 3) (3D non-homogenous coordinates)

  • aff : affine array shape (4, 4) (3D homogenous coordinates)

  • rfnorm : reflection in plane defined by normal vector and optional point.

aff2rfnorm(aff)

Mirror plane normal vector and point from affine aff

mat2rfnorm(mat)

Mirror plane normal vector from mat matrix.

rfnorm2aff(normal[, point])

Affine to mirror at plane defined by point and normal vector.

rfnorm2mat(normal)

Matrix to reflect in plane through origin, orthogonal to normal

aff2rfnorm

transforms3d.reflections.aff2rfnorm(aff)

Mirror plane normal vector and point from affine aff

Parameters
affarray-like, shape (4,4)
Returns
normalarray shape (3,)

vector normal to point (and therefore mirror plane).

pointarray shape (3,)

x, y, x coordinates of point that, together with normal, define the reflection plane.

Raises
ValueError

If there is no eigenvector for aff[:3,:3] with eigenvalue -1

ValueError

If determinant of aff[:3, :3] is not close to -1

ValueError

If there is no eigenvector for aff with eigenvalue 1.

Examples

>>> v0 = np.random.random(3) - 0.5
>>> v1 = np.random.random(3) - 0.5
>>> M0 = rfnorm2aff(v0, v1)
>>> normal, point = aff2rfnorm(M0)
>>> M1 = rfnorm2aff(normal, point)
>>> np.allclose(M0, M1)
True

mat2rfnorm

transforms3d.reflections.mat2rfnorm(mat)

Mirror plane normal vector from mat matrix.

Parameters
matarray-like, shape (3,3)
Returns
normalarray shape (3,)

vector normal to point (and therefore mirror plane)

Raises
ValueError

If there is no eigenvector with eigenvalue -1

ValueError

If determinant of mat is not close to -1

Examples

>>> normal = np.random.random(3) - 0.5
>>> M0 = rfnorm2mat(normal)
>>> normal = mat2rfnorm(M0)
>>> M1 = rfnorm2mat(normal)
>>> np.allclose(M0, M1)
True

rfnorm2aff

transforms3d.reflections.rfnorm2aff(normal, point=None)

Affine to mirror at plane defined by point and normal vector.

Parameters
normal3 element sequence

vector normal to point (and therefore mirror plane)

point3 element sequence

x, y, x coordinates of point

Returns
affarray shape (4,4)

Notes

See rfnorm2mat()

Examples

>>> normal = np.random.random(3) - 0.5
>>> point = np.random.random(3) - 0.5
>>> R = rfnorm2aff(normal, point)
>>> np.allclose(2., np.trace(R))
True
>>> np.allclose(point, np.dot(R[:3,:3], point) + R[:3,3])
True

rfnorm2mat

transforms3d.reflections.rfnorm2mat(normal)

Matrix to reflect in plane through origin, orthogonal to normal

Parameters
normalarray-like, shape (3,)

vector normal to plane of reflection

Returns
matarray shape (3,3)

Notes

http://en.wikipedia.org/wiki/Reflection_(mathematics)

The reflection of a vector v in a plane normal to vector a is:

\[\mathrm{Ref}_a(v) = v - 2\frac{v\cdot a}{a\cdot a}a\]

The entries of the corresponding orthogonal transformation matrix R are given by:

\[R_{ij} = I_{ij} - 2\frac{a_i a_j}{\|a\|^2}\]

where \(I\) is the identity matrix.