Re: how to find the inverse mapping matrix?
- From: ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx (Roger Stafford)
- Date: Mon, 30 Apr 2007 02:32:20 GMT
In article <ef555c3.-1@xxxxxxxxxxxxxxxxxxxxxxx>, "Yang Zhang"
<zhyang99@xxxxxxxxxxx> wrote:
Hi all,------------------
I am having a relatively straight forward question like this:
x1 = L1*cos(q1)+ L2 * cos(q1+q2) + O1;
x2 = L1*sin(q1) + L2 * sin(q1+q2) + O2;
L1, L2, O1 and O2 are constants; q1 and q2 are variables
How can I get the mapping equations from x to q?
Thanks a lot,
Yang
This can viewed as a problem in vectors in the x-y plane. For
convenience, rewrite your equations as:
x = a*cos(p) + b*cos(q)
y = a*sin(p) + b*sin(q)
where x = x1-O1, y = x2-O2, a = L1, b = L2, p = q1, and q = q1+q2. I will
assume here that a and b are non-negative numbers.
Consider the three vectors in the x-y plane:
1) The vector pointing from (0,0) to (x,y). If it makes an angle t with
the x-axis and has length c, we have x = c*cos(t), and y = c*sin(t).
2) The vector from (0,0) to (a*cos(p),a*sin(p)). It has length a and
makes an angle p with respect to the x-axis.
3) The vector from (0,0) to (b*cos(q),b*sin(q)). It has length b and
makes and angle q with respect to the x-axis.
In order to satisfy the above equations, it is clear that the vector in 1)
must be the vector sum of the vectors in 2) and 3), so this becomes a
problem in trigonometry. The vector in 1) is known and we must find what
the angles p and q must be to construct a triangle with sides a and b
where the third side is c. If we choose to start the 2) vector at (0,0),
there are two solutions to this, symmetrically on opposite sides of the
(x,y) vector.
All of this explanation above should then make sense of the following
matlab code:
t = atan2(y,x);
c = sqrt(x^2+y^2);
s = (a+b+c)/2;
alpha = 2*atan2(sqrt((s-b)*(s-c)),sqrt((s*(s-a)));
beta = 2*atan2(sqrt((s-a)*(s-c)),sqrt((s*(s-b)));
% The two solutions are:
p = t + beta;
q = t - alpha;
% and
p = t - beta;
q = t + alpha;
Note: The formulas for alpha and beta, using s, are from standard formulas
for solving oblique triangles given their three sides. If p or q come out
with values greater than 2*pi or negative, then 2*pi can be subtracted or
added accordingly if desired.
Roger Stafford
.
- Follow-Ups:
- Re: how to find the inverse mapping matrix?
- From: John D'Errico
- Re: how to find the inverse mapping matrix?
- References:
- how to find the inverse mapping matrix?
- From: Yang Zhang
- how to find the inverse mapping matrix?
- Prev by Date: Re: How to perform double summation in matlab.
- Next by Date: Re: Graph Binary Pulse Sequence
- Previous by thread: Re: how to find the inverse mapping matrix?
- Next by thread: Re: how to find the inverse mapping matrix?
- Index(es):
Relevant Pages
|