This must be a common problem, but I'm unable to crunch out a solution.
In the attached jpg, I need to specify x1, y1, x2 and y2 in terms of r1, r2, H and W. I'm stuck!
This is a tool path for my lathe. The cutting tool starts in the bottom right, and the user wants move to a new cutting diameter using a tapered step with two radii. The solution is in terms of variables because this is a very common operation and I am trying to create a subroutine where the user will simply enter the height and width of the step as shown, and the two radii.
In order to do this, my subroutine specifies coordinates for the center of radius 1 (i.e. (0,r1)), and the end point of radius 1 (i.e. (x1, y1)). The subroutine then specifies a taper by moving the tool to the coordinates (W-x2,H-y2). Finally, the subroutine specifies the center of radius 2 (W,H-r2), and the end point (W,H).
I got spoiled by an obscure CAD program way to long ago when it comes to doing geometry calculations. How?
There was an older parametric cad program called DesignView. It was sold by ComputerVision. It was and still is a VERY sophisticated sketch pad that did these exact things for engineers in the early 90's.
It got bloated out of existance by CV and was ultimately "retired" by the folks who absorbed CV, the current suppliers of Pro E. A godsend to folks who need simple yet powerful 2D cad program that does MANY difficult PITA calculations (areas, centroids, CG, MOI, etc) once you learn how to use it.
It would automatically calc all the stuff for you once you draw the shape the first time. Once you put in the appropriate fixed variables, it would calc the resultant generated ones as reference dimensions when you simple typed in the new design/dimension values. Neat and FAST.
Sadly, it is almost impossible to find but a great one if you can find it. Ver 2 runs on DOS while version 5 runs on DOS, 95, 98, 98SE and even ME. Don't think it will run on XP or the other late model frauds from M/S.
In case you can and do find a copy of DesignView ver 5, the attached cad file should do what you want/need to do...
Suppose we define angle (A) as the angle between the vertical axis and the line from the center of R1 to the tangency point on R1. This angle would be the same as the angle between the vertical axis and the line from the center of R2 to the tangency point on R2. With this definition of angle A, we know that:
x1 = SIN (A) * R1
x2 = SIN (A) * R2
y1 = R1 - COS (A) * R1
y2 = R2 - COS (A) * R2
Now, to find angle (A), we must construct two right triangles. For one triangle, draw a line from the center of R2 horizontally to the vertical line that intersects the center of R1. The length of this line, which is the height of our triangle, is W. Draw another line from the center of R1 to the center of R2. This is the Hypoteneus of the triangle. The third leg (base) of the triangle is from the center of R1 to the point where the horizontal leg of the triangle intersects the vertical axis. This leg is H-R1-R2 in length. From there it is simple to calcualate the length of the hypoteneus, and the angle that the hypoteneus makes with the horizontal axis, which we'll call A1.
The formula for this angle (A1) is simply: A1 = ATN ( ( H - R1 - R2) / W )
The length of the hypoteneus (D) is: D = SQRT ( W ^2 + ( H - R1 - R2) ^2 ) note: "^2" = "Squared"
Now, for the second triangle:
Draw a line from the center of R2, parallel to the line you plan to cut between the two radii. Now, draw a line from the center of R1 to intersect that line at a 90 degree angle. The base of this second triangle is R1 + R2, and the hypoteneuse is the same as the hypoteneus (D) of the previous triangle (above). What we're after here is the ANGLE between the hypoteneuse and the line you drew parallel to the cutting path. We'll call this angle A2.
The formula for that angle (A2) is: A2 = ARCSIN ( (R1 + R2) / D)
Now, for my next magical trick: The angle (A) that we were looking for at the start of this adventure is the sum of A1 and A2, which we just calculated. This is also the COMPLIMENT of the angle of the straight line you want to cut, which is 90 - A
Now that you have that angle (A), you can just plug A into the formulas given at the top to calculate x1, x2, y1 and y2. From there, you can do the rest.
Here's a drawing of the two triangles I was talking about last night.
Before you calculate angle A using A1 and A2, check to see if the distance H - R1 - R2 is positive or negative. If the two radii are large and this distance is negative, you will have to SUBTRACT A1 from A2 to get angle A instead of adding them together to get A.
The program I reffered to is/was "DESIGNVIEW" not Personal Designer.
Unless Personal Designer can open DesignView "DV suffix" files, it won't be of much help.
Then again, the folks at Pro E bought the DesignView code and maybe it will work/import. Supposedly the DesignView code was incorporated into a later version of ProE or one of it's lower ended sketch pads.
Will check it out (if it's free as I already have DV2, DV3 and the latest DV5).
I enjoyed working through your solution. (more stimulating than SUDOKU)
With my limited knowledge of trig, I would suggest calculating the other two angles of the triangles and then the angles A + A1 + A2 = 180deg.
Tell me if I'm wrong!
You're right that if you add up the internal angles of any triangle, you get 180 degrees.
There's frequently more than one solution to a problem like this. I just took ParadiseIsle's drawing and started sketching triangles until I noticed that it was possible to calculate that one unknown angle.
Trig isn't so hard if you know a few simple rules:
1) Any right triangle can be completely solved if you know the length of any two sides, or if you know one side and one angle (besides the 90 angle).
2) (Like you said): The 3 angles of a triangle always add up to 180 degrees
3) A line tangent to the circle is always perpendicular to the line from the tangent point to the circle center, making a right-triangle.
Then, just divide the problem into the "stuff we know" and the "stuff we don't know". In ParadiseIsle's puzzle, we know several dimensions, and we know that the line connecting the two radii are tangent to both circles. We also know the center points of both circles.
Sometimes you don't have enough information to solve the problem, and you can work on it forever without thinking of a solution. In this case, after I drew those two other triangles, I saw that it was possible to calculate that one important angle that we needed to solve the puzzle. Some of my sketching of triangles was simply "trial and error".
Don't worry about remembering all those Trig functions. You can always look them up when you need them. Look for a Trig reference chart that gives you all the little formulas, and use a calculator to get the actual numbers. There's a Trig function for each combination of "things you know" in a triangle, for example:
If you know the angle and the hypoteneus, use SIN to find the side closest to the angle, and COS to find the side opposite the angle
If you know the angle and one side, use TAN to find the ratio betwee the two sides. That lets you find the side you don't know.
The ARCSIN, ARCCOS, and ATAN functions are just working the SIN, COS, and TAN functions backwards. That's where you know two sides, but you don't know the angle. You've probably got a key for this on your calculate labeled "SIN-1". If the name of the function starts with "A", you're calculating the angle.
If you know the side and the base, and you want to find the hypoteneuse, you can square both sides, add them together, then take the square root.
Sometimes I don't use Trig for years, and I always enjoy working a problem like this just to see if I can still do it. It's a bit like riding a bike ...
If only High School teachers had not so often prefaced teaching Geometry and Trigonometry, and later on Calculus, with a comment something like; "I have to teach this but you will never use it...". (We need an emoticon for "sigh")