10 views (last 30 days)
I want to measure the angle of one of the sides of an object while looking at it from a side view. Then suppose the camera is rotated in a 60 degree arc in a plane that is parallel to the floor and I measure the angle of the same side. How can I compare these two angles to see if they're the same? The angle of the object is in reference to the angle it makes with the floor. So at 90 degrees it would be perpendicular to the floor. Thanks for any help.
Jonathan on 21 Nov 2011
If I understand this setup correctly, then the following is true. Take a line segment (I take this to be what you mean by side) perpendicular to the floor and tilt it 30 degrees to the right (from the observers position). Then the angle in question is 60 degrees. Now rotate the camera (observer) 90 degrees is either direction. The angle in question is now 90 degrees.
With this understanding, I have a solution that involves a projection based on the camera position. Suppose the base of the line segment is at (0, 0, 0), the other end of the segment is at S = (Sx, Sy, Sz), and the camera is at C = (Cx, Cy, 0). First, make S and C unit vectors by element-wise dividing by the respective norm. Project S onto the plane perpendicular to C via SP = S - S*C.C (where * is the dot product and . is the scalar product). Now, you need to find the line of intersection between the XY-plane and the plane perpendicular to C. Take the reference line R = C x (0, 0, 1) (where x is the cross product). Find the angle between the lines via SP * R = norm(SP) . norm® . cos(theta) (where theta is the angle between the lines). You may need to take the supplementary angle to theta if theta is greater than 90 degree.
S = [1,1,1];
C = [0,1,0];
SP = S - dot(S,C)*C;
R = cross(C, [0,0,1]);
theta = acosd(dot(SP, R)/(norm(SP) * norm(R)));
if theta > 90, then theta = 180 - theta; end
To get the second angle, rotate C about the z-axis the desires number of degrees (see Rotation Matrix for details).