Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have several positions (say A,B,C,..) and I know their coordinates (3d). From each point, if a certain ray is passing in a way to converge them at a given (known) point (say O). This point O is lie on a known planar surface (dark plane).


Now, my problem is to know, mutual locations and inter-relationship between each point with the plane. For example, I want to know that ray DO come first and then BO, AO, ..etc. Once I know the mutual location of them, then I want to know angle between each adjacent rays as it is my main intention. According to example case, I need to know DOB, BOA, AOC, COE, EOF. Additionally, I need to know angle between first ray and plane and as well as last ray and plane (as these DO & FO are next to plane). (I want to know only adjacent angles and not the all possible angles, therefore, the correct adjacency or point order is needed to avoid unnecessary computations). I guess, you can understand my question.

NOTE: A,B,C,...,O these points are not lie on a single plane. enter image description here

n is normal vector of the plane

Please, show me a way to do this without computing unnecessary computations as I want to implement this in c++.

share|cite|improve this question
Note that if these points are in 3D space, there may not be an easy or obvious way to order them by angle in a way that makes sense. – Tpofofn Jun 7 '13 at 2:19
@ Tpofofn: I am working on a 3D space. i.e. all my point are 3D points. – gnp Jun 7 '13 at 8:38
@Tpofofn: to simplify the case, i can project all points on to a vertical plane which passes through O and parallel to a plane which contains zenith vector and normal vector. – gnp Jun 7 '13 at 9:33
@Tpofofn: please tell me a way.. thanks – gnp Jun 7 '13 at 9:33
up vote 1 down vote accepted

You have to use scalar product: $$\vec u\cdot\vec v=|\vec u|\cdot|\vec v|\cdot\cos\angle(\vec u,\vec v)$$ So, the angle can be obtained by: $$\cos\angle(\vec u,\vec v)= \frac{u_1v_1+u_2v_2+u_3v_3}{\sqrt{{u_1}^2+{u_2}^2+{u_3}^2}\cdot \sqrt{{v_1}^2+{v_2}^2+{v_3}^2}}\,,$$ where $|\vec u|=\sqrt{{u_1}^2+{u_2}^2+{u_3}^2}$ by the Pythagorean theorem, and $u_1,u_2,u_3$ are the coordinates of $\vec u$. Also, if points are given by coordinates, the coordinates of vector $\vec{AB}$ can be calculated as $B-A$ (coordinatewise).

If $\vec n$ is a normalvector of the plane, then the angle between the plane and a vector $\vec u$ is $90^\circ-\angle(\vec u,\vec n)$.

For cute angles $\alpha,\beta$ we have $\ \alpha<\beta \iff \cos\alpha>\cos\beta$. So that we can order the angles by their cosinus, and no specific need for $\arccos$.

We also have

  • $\ \vec u\cdot\vec n>0 \ \iff\ \vec u$ is in the same halfspace as $\vec n$,
  • $\ \vec u\cdot\vec n<0 \ \iff\ \vec u$ is in the opposite halfspace as $\vec n$,
  • $\ \vec u\cdot\vec n=0 \ \iff\ \vec u$ is on the plane.
share|cite|improve this answer
thank you for the response. but i am sorry, i did not get clearly what you said. what is u1, u2, u3? Actually, i post this question because I feel I can not recognize (say point A and E), the point A is upper and not the down.. and similarly, E is down not in the upper.. the angle between two rays does not say whether these 2 points are upper part and not the down part and so on.. for me, I want to clearly figure out the reality of these rays with respect to the plane.. thanks,... any comments please. – gnp Jun 7 '13 at 9:28
$u_1,u_2,u_3$ are the coordinates of $\vec u$. If you know the normalvector ($\vec n$) of the plane, then the sign of the scalar product $\vec{OX}\cdot\vec n$ would tell whether $X$ is on the same side of the plane as $\vec n$ or on the opposite. This information together with $\angle(\vec{OX},\vec n)$ tells you everything about the situation. – Berci Jun 7 '13 at 9:41
Many thanks for the updating (I think, I couldn't tell you what I really need). as far as i understood, +,- signs tell whether the normal vector and ray vector are in the same direction or opposite. But, to recognize these rays, I need to know whether which rays fall within the red part and which rays fall within the green part. So, My main problem was to get this clearly. for eg. if the angle is 35 degree, this does not say that fall in which part (red, green)... any idea to get this please.. – gnp Jun 7 '13 at 10:35
I apologies you for my poor expression. Please guide me to solve this.. – gnp Jun 7 '13 at 10:37
I'm quite sure that whatever you are looking for, can be solved by scalar product. – Berci Jun 7 '13 at 17:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.