1

I understand the math in flipping vertex coordinates in a .obj vertices array to get the mirrored coordinate across a plane/axis. But, how do you populate the vertices array for an actual mirror operation (as opposed to just a flip)

skaffman
  • 398,947
  • 96
  • 818
  • 769
ina
  • 19,167
  • 39
  • 122
  • 201

1 Answers1

1

Normally you don't mirror by flipping vertex values, but by appliying an apropriate mirror transform matrix.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • what does the mirror matrix look like? how do you specify the variations depending on the vertex array? – ina Mar 09 '11 at 22:00
  • You can compose the mirror matrix the following way: First translate a point on the mirror plane (any point will do) to the origin, this is T. Then rotate the mirror plane perpendicular to one of the base vectors, let's say x, this is R. After this perform a reflection in the mirror plane by scaling with -1 in the x direction. After this rotate and translate back. So the mirror matrix M = T^-1 * R^-1 * S * R * T. The rotation and axial mirroring can be expressed as a single operation called Householder transformation, which can be written as H = I - v v^T (v being the reflection plane normal). – datenwolf Mar 09 '11 at 22:20
  • Take note that v v^T is a so called outer, or tensor product. So don't confuse this with the scalar/dot product. – datenwolf Mar 09 '11 at 22:21
  • The math is trivial, but how do you apply this programmatically to a mess of vertices? – ina Mar 11 '11 at 11:32
  • @ina: By multiplying each vertex position with the mirror matrix. – datenwolf Mar 11 '11 at 12:15
  • i wish it were that simple - my question still has to do with how do you make sure the ordering of the vertex matches that of the mirror matrix? – ina Mar 13 '11 at 09:37
  • What do you mean be "ordering"? Your vertices have each a position vector p, with elements p_1, p_2, … usually names p_x, p_y, p_z for a 3D vector. And you have some 4x4 matrix T mapping from one 3D space M into another one M' and you can tranform p → p' by multiplication p' = T p – datenwolf Mar 13 '11 at 09:43