I have some 3dPoints given and now I have to calculate the angel between every Point and the vertical.
In the code below you can see my 3D Points which are included in controlPoints.
numPoints give the Number of Points and I read all Coordinates for x, y, z.
Now I neet to identify the two points which are generate a vertical line (e.g. which have the lowest angle between point and a vertival line)
Can someone help me?
That doesn't answer the "angle of a point" question. Lets ignore that for a moment.
Lets have a polygon of four points {a,b,c,d}. A square. We can draw lines that pass through two points:
{ab, ac, ad, bc, bd, cd}. Six lines. Edges and diagonals of the square. (A two-point polygon has one line, a triangle has three, and every additional point contributes to combinatorial explosion.)
When you have two points, you can translate both with same vector so that the first point becomes (0,0,0). Treat he translated second point as directional vector. Lets call it vB.
I presume that you mean by vertical a line colinear with (0,0,z). A vector from (0,0,0) to (0,0,1) is unit length and vertical. Lets call it vZ.
Make your directional vector unit length: vB' = vB/l|vB|. Compute dot product vZ*vB'. Drop the sign. The line with largest result is closest to vertical.
Back to the square. I draw it on the floor. All of its lines are equally orthogonal to the vertical line.