**1**

# Geometry triangle problem

Started by yahastu, Mar 10 2012 07:24 PM

6 replies to this topic

###
#1
Members - Reputation: **152**

Posted 10 March 2012 - 07:24 PM

Imagine a camera orbiting an spherical object. For a given orbit rotation, I'm trying to find out what the maximum change in the observed image angle of any point on the surface of the spherical object would be. I've reduced the problem to the diagram shown below.

The object is centered at A. B is the original camera location and D is the rotated camera location after orbiting. C is the point on the surface of the object. The original observed angle is ABC = atan( r/d). However, I can't figure out how to calculate Theta2 = angle ADC.

The object is centered at A. B is the original camera location and D is the rotated camera location after orbiting. C is the point on the surface of the object. The original observed angle is ABC = atan( r/d). However, I can't figure out how to calculate Theta2 = angle ADC.

Sponsor:

###
#2
Crossbones+ - Reputation: **2116**

Posted 10 March 2012 - 08:26 PM

Hi Yahastu,

I would approach this problem by first converting the points into a set of vectors where,

A = (0,0)

B = (-d,0)

C = (0,r)

The dot product is related to the cosine of the angle between two vectors so what I want is to calculate the dot product of the vector AD and CD. That means I need to calculate D. D is a rotation of B about A so multiplying B by the appropriate rotation matrix gives

D = (-d*cos(theta1), d*sin(theta1))

The dot product between AD and CD is,

(C - D).(A - D) = |C - D||A - D| cos(theta2)

Therefore,

theta2 = acos((C - D).(A - D)/(|C - D||A - D|)).

-Josh

I would approach this problem by first converting the points into a set of vectors where,

A = (0,0)

B = (-d,0)

C = (0,r)

The dot product is related to the cosine of the angle between two vectors so what I want is to calculate the dot product of the vector AD and CD. That means I need to calculate D. D is a rotation of B about A so multiplying B by the appropriate rotation matrix gives

D = (-d*cos(theta1), d*sin(theta1))

The dot product between AD and CD is,

(C - D).(A - D) = |C - D||A - D| cos(theta2)

Therefore,

theta2 = acos((C - D).(A - D)/(|C - D||A - D|)).

-Josh

--www.physicaluncertainty.com

--linkedin

--irc.freenode.net#gdnet

###
#3
Moderators - Reputation: **8581**

Posted 10 March 2012 - 09:17 PM

Given that you know r and d, and that you can calculate the distance between D and C, you can use the Law of Cosines.

In this case, the distance between D and C is

Thus, the angle ADC would be calculated as:

c^2 = a^2 + b^2 - 2ab*cos(theta)

In this case, the distance between D and C is

**a**and the distance between A and D is**b**. The distance between A and C is**c**. Re-arranging the above equation gets you:cos(theta)=(a^2+b^2-c^2)/2ab

Thus, the angle ADC would be calculated as:

ADC=acos( ( (AD)^2+(CD)^2-(CA)^2 ) / 2*(AD)*(CD) )

###
#4
Members - Reputation: **152**

Posted 10 March 2012 - 09:32 PM

Thanks both of you. jjd, your approach of converting into vectors is a good method to keep in mind for the future as well!

I was hoping to rearrange the solution in order to be able to compute the necessary value of Theta1 in order to achieve a given value of Theta2. However that is not possible via these solution methods. Do you think there is a closed form solution for the reverse problem?

I was hoping to rearrange the solution in order to be able to compute the necessary value of Theta1 in order to achieve a given value of Theta2. However that is not possible via these solution methods. Do you think there is a closed form solution for the reverse problem?

###
#5
Members - Reputation: **1072**

Posted 10 March 2012 - 11:19 PM

Do you know what the positions of the points in the diagram are and can they be used in the calculations or must it be limited to theta1, r, and d?

EDIT: Ok, after looking at the problem, I think I managed to find a single "formula" that will solve everything in pretty much one step, although you should take precaution dealing with various things like diving by zero and the fact that the formula uses fairly inefficient means to calculate the angle (square roots, sin, arccos, etc). Also, do take into consideration that arccos is only defined on a certain interval, that interval being [-1, 1]. If the ratio is outside of that, then you'll run into trouble, although I think the only real cause of that is if the triangle is impossible (which I think may actually happen so do be careful).

So, the end result isn't all that straightforward either. I don't really know how to put it in fancy image form, so I'll have to convey it via good ol' textual means:

theta2 = arccos( (d - r*sin(theta1))/sqrt(r^2 + d^2 - 2*a*d*sin(theta1)) )

Also, I have not tested this on anything. I wrote a proof to make sure I wasn't doing something wrong and it all seems to be OK. Again, I don't know how to make fancy diagrams so relied on caveman technology. Here is the writing:

http://img525.imageshack.us/img525/1002/lawofcosineproof.jpg

I apologize for the handwriting

EDIT: Ok, after looking at the problem, I think I managed to find a single "formula" that will solve everything in pretty much one step, although you should take precaution dealing with various things like diving by zero and the fact that the formula uses fairly inefficient means to calculate the angle (square roots, sin, arccos, etc). Also, do take into consideration that arccos is only defined on a certain interval, that interval being [-1, 1]. If the ratio is outside of that, then you'll run into trouble, although I think the only real cause of that is if the triangle is impossible (which I think may actually happen so do be careful).

So, the end result isn't all that straightforward either. I don't really know how to put it in fancy image form, so I'll have to convey it via good ol' textual means:

theta2 = arccos( (d - r*sin(theta1))/sqrt(r^2 + d^2 - 2*a*d*sin(theta1)) )

Also, I have not tested this on anything. I wrote a proof to make sure I wasn't doing something wrong and it all seems to be OK. Again, I don't know how to make fancy diagrams so relied on caveman technology. Here is the writing:

http://img525.imageshack.us/img525/1002/lawofcosineproof.jpg

I apologize for the handwriting

"If highly skilled generalists are rare, though, then highly skilled

My personal links

- Khan Academy - For all your math needs

- Java API Documentation - For all your Java info needs

- C++ Standard Library Reference - For some of your C++ needs ^.^

*innovators*are priceless." - ApochPiQMy personal links

- Khan Academy - For all your math needs

- Java API Documentation - For all your Java info needs

- C++ Standard Library Reference - For some of your C++ needs ^.^

###
#6
Moderators - Reputation: **8581**

Posted 11 March 2012 - 04:11 AM

Well, if you know the value of Theta2, as well as the lengths of the AD and AC line segments, you can easily calculate the value of DAC, then subtract that from 90 degrees to get Theta1. Just re-arrange the Law of Cosines to get what you need.

###
#7
Members - Reputation: **1072**

Posted 11 March 2012 - 08:57 AM

EDIT: nvm, that was the answer to the "reverse problem." I seem to have missed that.

"If highly skilled generalists are rare, though, then highly skilled

My personal links

- Khan Academy - For all your math needs

- Java API Documentation - For all your Java info needs

- C++ Standard Library Reference - For some of your C++ needs ^.^

*innovators*are priceless." - ApochPiQMy personal links

- Khan Academy - For all your math needs

- Java API Documentation - For all your Java info needs

- C++ Standard Library Reference - For some of your C++ needs ^.^