MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / reflection_matrix

Function reflection_matrix

utils/utils_poses/ATE/transformations.py:453–476  ·  view source on GitHub ↗

Return matrix to mirror at plane defined by point and normal vector. >>> v0 = numpy.random.random(4) - 0.5 >>> v0[3] = 1.0 >>> v1 = numpy.random.random(3) - 0.5 >>> R = reflection_matrix(v0, v1) >>> numpy.allclose(2., numpy.trace(R)) True >>> numpy.allclose(v0, numpy.dot

(point, normal)

Source from the content-addressed store, hash-verified

451
452
453def reflection_matrix(point, normal):
454 """Return matrix to mirror at plane defined by point and normal vector.
455
456 >>> v0 = numpy.random.random(4) - 0.5
457 >>> v0[3] = 1.0
458 >>> v1 = numpy.random.random(3) - 0.5
459 >>> R = reflection_matrix(v0, v1)
460 >>> numpy.allclose(2., numpy.trace(R))
461 True
462 >>> numpy.allclose(v0, numpy.dot(R, v0))
463 True
464 >>> v2 = v0.copy()
465 >>> v2[:3] += v1
466 >>> v3 = v0.copy()
467 >>> v2[:3] -= v1
468 >>> numpy.allclose(v2, numpy.dot(R, v3))
469 True
470
471 """
472 normal = unit_vector(normal[:3])
473 M = numpy.identity(4)
474 M[:3, :3] -= 2.0 * numpy.outer(normal, normal)
475 M[:3, 3] = (2.0 * numpy.dot(point[:3], normal)) * normal
476 return M
477
478
479def reflection_from_matrix(matrix):

Callers

nothing calls this directly

Calls 1

unit_vectorFunction · 0.85

Tested by

no test coverage detected