[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Iterative Solution
From: |
Ian McCallion |
Subject: |
Fwd: Iterative Solution |
Date: |
Tue, 28 Aug 2018 09:07:00 +0100 |
should have copied help-octave
---------- Forwarded message ---------
From: Ian McCallion <address@hidden>
Date: Tue, 28 Aug 2018 at 09:05
Subject: Re: Iterative Solution
To: <address@hidden>
This is simple geometry. Take the line between the centres at the
desired point of the tool. Starting with this line as the hypotenuse
complete a right-angled triangle using horizontal and vertical lines.
Apply Pythagoras theorem.
## given a circle, C1,
## center (3+1/2)/2, (3+1/2)/2+1+1/4, radius (3+1/2)/2
## and a line, L1,
## x=(3+1/2)/2 - (3/4+20/1000)/2 - 1/2,
## find a circle, CT1, of radius 1/8 such that it is tangent to both
## L1 and C1. CT1 is outside C1 and between L1 and the origin.
## The x value of center(CT1) is
## (3+1/2)/2 - (3/4+20/1000)/2 - 1/2 - 1/8.
## The y value of center(CT1) is that value that results in the
## distance from center(C1) to center(CT1) is equal to
## radius(C1) + radius(CT1)
## Start with y = 0 and increase y until
## d = distance( center(C1) - center(CT1) )
## = sqrt( ((3+1/2)/2 - 1/8)^2 + ((3+1/2)/2+1+1/4 - x_value)^2)
## d - ( (3+1/2)/2 + 1/8 ) = 0
function [y1] = dean()
x0 = (3+1/2)/2
y0 = (3+1/2)/2+1+1/4
r0 = (3+1/2)/2
x1 = (3+1/2)/2 - (3/4+20/1000)/2 - 1/2 - 1/8
y1 = 0
r1 = 1/8
hyplen=1.75+.125
sidexlen=1.75-.74
sideylen=sqrt(hyplen^2-sidexlen^2)
y1=y0-sideylen
## maple answer y1 == 1.420276923
endfunction;
Cheers... Ian
On Tue, 28 Aug 2018 at 07:18, Thomas D. Dean <address@hidden> wrote:
>
> I was watching a machinist make a part. The portion of the part I was
> interested in consisted of a circle and a line. The machinist wanted to
> locate a tool such that it was tangent to the line and the circle.
>
> I used an iterative method to calculate the location of the center of
> the tool circle. This took 71 iterations. Must be a better method.
>
> Tom Dean
>
> ## given a circle, C1,
> ## center (3+1/2)/2, (3+1/2)/2+1+1/4, radius (3+1/2)/2
> ## and a line, L1,
> ## x=(3+1/2)/2 - (3/4+20/1000)/2 - 1/2,
> ## find a circle, CT1, of radius 1/8 such that it is tangent to both
> ## L1 and C1. CT1 is outside C1 and between L1 and the origin.
>
> ## The x value of center(CT1) is
> ## (3+1/2)/2 - (3/4+20/1000)/2 - 1/2 - 1/8.
>
> ## The y value of center(CT1) is that value that results in the
> ## distance from center(C1) to center(CT1) is equal to
> ## radius(C1) + radius(CT1)
> ## Start with y = 0 and increase y until
> ## d = distance( center(C1) - center(CT1) )
> ## = sqrt( ((3+1/2)/2 - 1/8)^2 + ((3+1/2)/2+1+1/4 - x_value)^2)
> ## d - ( (3+1/2)/2 + 1/8 ) = 0
>
> function [x1, y1] = find_loc()
> x0 = (3+1/2)/2; y0 = (3+1/2)/2+1+1/4; r0 = (3+1/2)/2;
> x1 = (3+1/2)/2 - (3/4+20/1000)/2 - 1/2 - 1/8; y1 = 0; r1 = 1/8;
> ## maple answer y1 == 1.420276923
> dy = 1;
> d = sqrt( (x0 - x1)^2 + (y0 - y1)^2);
> err = d - (r0 + r1);
> s = sign(err);
>
> iters = 1;
>
> while (abs(err) > 1e-15)
> if (sign(err) == s);
> y1 += s*dy;
> else
> s = sign(err);
> dy /= 10;
> y1 += s*dy;
> endif
> d = sqrt( (x0 - x1)^2 + (y0 - y1)^2);
> err = d - (r0 + r1);
> iters++;
> endwhile
>
> printf("iterations %d\n", iters);
>
> endfunction;
>
>
- Iterative Solution, Thomas D. Dean, 2018/08/28
- Message not available
- Fwd: Iterative Solution,
Ian McCallion <=