APPENDIX 2
A.1 - analytical position solution for four-bar
In Section 2 of the lecture notes, we arrived at the following equation in our attempt to
find the position solution for the mechanism:
2r1r4 cos 4 + 2r2 r4 cos( 2 4 ) = r22 + r42 + r12 2r1r2 cos 2 r32
where r1, r2 , r3 and r4 are known vector lengths and 2 is the (known) input angle for the
mechanism. Our goal is to determine the value(s) of 4 that satisfies the above equation.
The next step in this solution process is to convert the left-hand-side of the above
equation to the form of: Acos( 4 ) . To this end, we will write the left-hand-side of the
above as1:
2r1r4 cos 4 + 2r2 r4 cos( 2 4 ) = 2r1r4 cos 4 + 2r2 r4 (cos 2 cos 4 + sin 2 sin 4 )
= 2( r1r4 + r2 r4 cos 2 ) cos 4 + 2( r2 r4 sin 2 ) sin 4
2( r r + r r cos 2 )
2( r r sin 2 )
= A 1 4 2 4
cos 4 + 2 4
sin 4
A
A
where
A=2
( r1r4 + r2 r4 cos 2 )
+ ( r2 r4 sin 2 )
If we make the following definition,
cos =
2( r1r4 + r2 r4 cos 2 )
A
then we see that2:
sin =
A sin
2( r2 r4 sin 2 )
A
A cos
With the above, we now have:
2r1r4 cos 4 + 2r2 r4 cos( 2 4 ) = A[cos cos 4 + sin sin 4 ]
= Acos( 4 )
1
In the first line of this equation, we have used the trigonometric identity of:
cos( a b) = cos acosb + sin asinb .
Use the trigonometric identity of cos2 + sin 2 = 1 to verify this.
where3:
tan =
2( r2 r4 sin 2 ) / A
sin
=
cos 2( r1r4 + r2 r4 cos 2 ) / A
= atan2( r2 r4 sin 2 , r1r4 + r2 r4 cos 2 )
Therefore, our original equation above takes on the desired form of:
Acos( 4 ) = r22 + r42 + r12 2r1r2 cos 2 r32
Solving this for 4 gives:
r 2 + r 2 + r 2 2r1r2 cos 2 r32
4 = + cos1 2 4 1
r22 + r42 + r12 2r1r2 cos 2 r32
= atan2( r2 r4 sin 2 , r1r4 + r2 r4 cos 2 ) + cos
2 r r + r r cos 2 + r r sin
(24
2)
2)
(14 2 4
1
Remarks
1. Usage of the atan2 function will always give a unique value for the angle . If
you do not have the atan2 function at your disposal, then you will need to
determine the correct quadrant for the old-fashioned way -- if is written as
N
= atan , then the correct quadrant for is determined by considering the signs
D
of N and D using the following figure:
N >0, D < 0
N >0, D > 0
N < 0, D < 0
N < 0, D > 0
atan2 is a common function in most programming languages that allows one to
obtain the correct quadrant of the angle when finding the inverse tangent of an
x
argument. Here, = atan2( x, y ) corresponds to tan = .
y
2. Depending on the size of the argument B found in the bracket, a real value for the
cos1 ( B) function in the above expression for 4 might not exist, and if it does, it
might not be unique. In particular, cos1 ( B) will give either: i) no solution, ii) one
solution or iii) two solution:
i) If B > 1, then there are no realvalues of cos1 ( B) . This says that the
mechanism cannot take on a position corresponding to this input angle 2 .
ii) If B = 1, then there is a single value of cos1 ( B) = 0 . Similarly, if B = 1 ,
there is a single value of cos1 (
B) = . Physically, the coupler link 3 and
output link 4 are aligned in these two cases as shown below.
iii)
For B < 1, there are two values of cos1 ( B) . If B > 0 , then the two values
of cos1 ( B) are in the first and fourth quadrants. If B < 0 , then the two
values of cos1 ( B) are in the second and third quadrants. Therefore, two
position mechanism positions,
1 and
2 below, are possible for B < 1
position 1
3
4
2
3
4
position 2
A.2 Matlab code for Newton Raphson example in lecture
Main program for Newton-Raphson solution:
clear
tol=1.e-8;
% make initial guess x0 a COLUMN vector
x0(1,1)=0.5;
x=newton_raphson(x0,tol);
Function newton_raphson for solving:
f ( x ) = x 3 6x 2 + 11x 6 = 0
function [x]=newton_raphson(x0,tol)
x=x0;
err=1.e10;
% in the loop make f a COLUMN vector and J a SQUARE matrix
while err > tol
f(1,1)=x.^3-6*x.^2+11*x-6;
J(1,1)=3*x.^2-12*x+11;
dx=-inv(J)*f;
err=max(abs(dx));
x=x+dx;
[err,x]
end