How to solve overdetermined vector equation?

Hi,
I have an equation like this:
sin(a1)*sin(a2)=v1, -cos(a1)*sin(a2)=v2, cos(a2)=v3
v1, v2 and v3 are components of a vector I know. How can I calculate the equation to get the results of a1 and a2?
Thanks!

回答(2 个)

Use lsqnonlin to minimize the function
F(a1,a2) = (sin(a1)*sin(a2)-v1)^2 + (cos(a1)*sin(a2)+v2)^2 + (cos(a2)-v3)^2
Best wishes
Torsten.
Use pen and paper, draw the standard little sketch for spherical-and-Cartesian coordinates...
Then you get:
a2 = acos(v3);
% sin(a1)/cos(a1) = -v1/v2, so
a1 = atan2(v1,-v2); % check the order of the arguments to atan2
% perhaps this is a numerically better estimate of a2:
a2 = atan((v1^2+v2^2)^(1/2)/v3);
HTH

2 个评论

I get
a2 = -atan((v1^2+v2^2)^(1/2)/v3);
Best wishes
Torsten.
Realy? Oh, well - no reason for us to get all agitated about sign conventions for rotational angles...
(I've seen 4 different definitions of azimuth used in astronomy! Clock-wise from North, counter-clock-wise from East, clock-wise from East, clock-wise from East)

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by