• Advertisement


This topic is now archived and is closed to further replies.

Flipping a vertex

This topic is 5992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi there, im currently working on my reflective surfaces which are now working however i would like them to rotate etc which in order to do i need to flip the vertex around the quad. Currently im just scaling by -1 in the Y direction to do the flip but I cant see how this would work around any plane. Does anyone know of a matrix which i can apply to perform this transformation. Thanks Mark.

Share this post

Link to post
Share on other sites
I take it you have the normal to the quad? Doesn't matter if the normal is pointing to the reflective side or away from the reflective side. Then lets do a little analysis to figure this out:

Lets say the point you want to reflect is A = (Ax, Ay, Az).

And lets say that a point on the quad is B = (Bx, By, Bz). (It can be any point on the quad, but you *must* have this point to reflect about an arbitrary quad.)

And lets say that the normal of the quad is N = (Nx, Ny, Nz). It needs to be a unit vector.

And lets say that the *reflected* version of A is R = (Rx, Ry, Rz). This is what we want to calculate.

You can do the reflection like this:

First, calculate D = vector = (Ax - Bx, Ay - By, Az - Bz)

D is a temporary vector that points from the quad to the point we want reflected. D may not be perpendicular to the quad. We're actually going to reflect D about the plane, and then add B back to get the reflection of A. A portion of D points along the normal vector N, and a portion points parallel to the plane. We're really just splitting D into two components. The component of D that is normal to the plane is:

D_normal_to_quad = N * DotProduct(D, N)

where DotProduct(D, N) = (Ax-Bx)*Nx + (Ay-By)*Ny + (Az-Bz)*Nz

And the other part of D is:

D_parallel_to_quad = D - D_normal_to_quad

See what we did. To project D into the plane of the quad, we merely removed the portion of D pointing outside the quad and we are left with a point inside the quad.

Now, to find the *reflection* of D about the quad just take the opposite of D_normal_to_quad:

D_reflected = D_parallel_to_quad - D_normal_to_quad

which you can expand to see is the same as:

D_reflected = D - 2 * D_normal_to_quad

And D_reflected is a vector, measured relative to point B, that is reflected about the quad from the original vector D.

Now that we have D_reflected, just add B back to get R:

R = B + D_reflected

And R is the answer!

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Edited by - grhodes_at_work on September 24, 2001 6:45:59 PM

Edited by - grhodes_at_work on September 24, 2001 6:46:47 PM

Share this post

Link to post
Share on other sites

  • Advertisement