# Finding a point on a plane perpendicular to two other points on the same plane

I'm working on a 3D perspective game and it would help if you could answer this:

Plane $P$ is defined as: $xf \cdot x + yf \cdot y + zf \cdot z + G = 0$

I know point $p$ $(xp, yp, zp)$ and point $f$ $(xf, yf, zf)$, and they each lie on plane $P$.

$xf, yf, zf, G, xp, yp, zp$ are all known.

I am looking for some point $q$'s coordinates. Point $q$ lies on plane $P$. Angle pqf forms a right angle.

*NOTE *: $f$ is at the same height as $q$ ($zq = zf$) and $p$ is above $q$.

I tried to use the dot product rule as well as the intersection of three planes in order to find point q, but it seemed there were too many unknown variables (which doesn't make sense to me).

You have three variables for the point $Q = (Q_x,Q_y,Q_z)$. You have that $\angle PQF$ is right angle hence $(P-Q) \cdot (F-Q) = 0$. Also you have that $Q_z = F_z$ and finally you have that $xf \cdot Q_x + yf \cdot Q_y + zf \cdot Q_z + G = 0$, as $Q$ lies on the plane. These three equation should give a solution (whenever possible) for $Q = (Q_x,Q_y,Q_z)$.
Any point (other than $p$ or $q$ themselves) on the circle that has $p$ and $q$ as endpoints of a diameter and lies within the plane will create the right angle you’re looking for. As a practical way finding such a point, rotate either $p$ or $q$ about the normal to the plane through their midpoint.
Alternatively, once you’ve found the midpoint $c$, you can use a series of cross products to find a vector that’s orthogonal to both the plane normal and $p-c$ (and also $q-c$). Adjust its length to equal $\|p-c\|$.
• Excellent suggestion, amd. Especially because one can implement the rotation using Rodrigues' rotation formula, which for a ±90° rotation boils down to $$\vec{v}' = \hat{k} \times \vec{v} \pm \hat{k} ( \hat{k} \cdot \vec{v} )$$where $\hat{k}$ is the unit vector representing the rotation axis; here, $\hat{k} = f / \lVert f \rVert = f / \sqrt{f \cdot f}$, $\vec{v} = ( \vec{q} - \vec{p} ) / 2$, and the resulting point $r$ is $\vec{p} + \vec{v} + \vec{v}'$ making $\angle prq = 90°$. – Nominal Animal Jul 13 '17 at 8:29