# Mirorring a set of Points

Let's say I have a cloud of points, and I know the equation of the symmetry plane. I'd like to mirror every single point with respect to this plane. It might be much simpler than I think, but I have some difficulties on finding a way to do that in Java.

I have the $x,y,z$ position of each point, its distance from the symmetry plane, the equation of the plane. How can I find the $x,y,z$ of the mirrored point ? I was trying to find the point of intersection between the symmetry plane and the line that passes through the point I have to mirror and with its normal being the symmetry plane.

I think it's more an Algebra problem than a Java one. But I still don't know how to do it without Java. I was trying to calculate a linear system :

Line: $ax+by+cz+d=0$

Plane $a'x+b'y+c'z+d' =0$

But it looks like some informations are missing and I can't solve it (only two equations). I hope I explained myself properly.

-

## migrated from stackoverflow.comDec 6 '11 at 22:09

This question came from our site for professional and enthusiast programmers.

"But I still don't know how to do it without Java" - Sorry, but this really is a math problem. Also, you should put a 'homework' label on this if that's what it is. If you can figure out how to do it mathematically, I'm sure everyone would be happy to help you get it working in java –  jeff Dec 6 '11 at 16:17
It's not homework and yes while I was writing I figured that it was more a Math problem than a Java one.. –  G4bri3l Dec 6 '11 at 16:25
Should I delete this one and ask it on math.se ? –  G4bri3l Dec 6 '11 at 16:27
–  leonbloy Dec 6 '11 at 16:30
Thanks leonbloy I think your suggestion should work =D –  G4bri3l Dec 6 '11 at 16:38

Your can solve this problem using vector algebra.

Now suppose we have a point $P$ and a plane with normal vector $\vec{n}(|\vec{n}|=1)$ passing through point $P_0$. To find the symmetric point $P'$, we find the projection $K$ of $P$ on the plane first: $$\vec{KP} = |\vec{KP}|\cdot \vec{n} = (\vec{P_0 P} \cdot \vec{n})\vec{n}$$

Note that $\vec{P_0 P} \cdot \vec{n}$ is actually equals to $$\frac{ax + by + cz + d}{\sqrt{a^2+b^2+c^2}}$$ You can use this form or just use the $P_0$ method in your program. Finally, we get $P'$ easily: $$\vec{OP'} = \vec{OP} - 2\vec{KP}$$ where $O$ is the origin point $(0, 0, 0)$.

Here I suppose you use a vector library in your Java program, so your functions can handle vectors. The following pseudocode shows how to find $P'$, tough it's not Java.

function findSymmetricPoint(p:vector3D, n:vector3D, p0:vector3D) -> p1:vector3D
n = n.normalized()
return p - n.dot(2 * (p - p0).dot(n))
end

-