# TheSwamp

## Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on April 07, 2021, 05:03:03 AM

Post by: Peter2 on April 07, 2021, 05:03:03 AM
There is the standard command to create a circle with "tan - tan - rad". Someone who knows a solution to create an arc with "tan tan - rad"?
(Example with new yellow arc between red and green arc see attachment)
Title: Re: Create ARC with TAN-TAN-RAD
Post by: BIGAL on April 07, 2021, 10:06:45 PM
Its a question that is often raised there are 4 possible solutions which is why TTR is close but then have to trim. In some 3rd party Civil  software this was solved by asking for approximate new arc centre pt.

Just did something worked great drew a couple more arcs failed miserably, need to look into that math answer for 3 arcs.

Title: Re: Create ARC with TAN-TAN-RAD
Post by: kirby on April 09, 2021, 01:30:41 PM
Hi Peter

Here is code that does just that, draw an arc transition between two arcs.  It will not do a reverse curve (S curve), just curves that bulge in the same direction.  Only uses arcs or circles as input, no polyarcs (but could be updated).

The workhorse is a routine that finds the intersection of 2 circles (which can be 2 points, a single point of tangency, or no intersections).  The 'trick' is that radials of tangent arcs must pass through the centre points of both arcs/circles.

Old code clipped out of a larger pavement geometry library, but I did a cleanup, sprinkled lots of comments throughout and added a quick help routine that lists the commands.

Regards,
Kirby
Title: Re: Create ARC with TAN-TAN-RAD
Post by: tombu on April 10, 2021, 03:36:55 AM
FILLET command set to [No trim] does that.
Option is controlled by the TRIMMODE (System Variable)
Title: Re: Create ARC with TAN-TAN-RAD
Post by: BIGAL on April 10, 2021, 08:34:16 PM
tombu only works for certain 2 arc patterns. Was getting a internal answer rather than external.

Kirby I think your on the money was looking at a option of like a W arc, a S arc, C a arc arc arc as requested.

Would do a dcl image please choose style, need some time to play.

Have the advantage of VL using intersectwith for working out trim side of circle or arcs simplify the coding did have that working as 1st attempt for "W" style but tombu answer much simpler. Will work on the C option next as I am pretty sure code will be shorter, using VL is shorter then assoc.

A quick comment but may work out wrong for a S add diff to 1st arc subtract diff for 2nd arc draw circles get 2 point possible solution.

(http://)

Title: Re: Create ARC with TAN-TAN-RAD
Post by: tombu on April 11, 2021, 07:06:41 PM
tombu only works for certain 2 arc patterns. Was getting a internal answer rather than external.
What about this old lisp of yours that draws an arc clockwise between 2 lines or arcs in the direction of the line picks?
Title: Re: Create ARC with TAN-TAN-RAD
Post by: BIGAL on April 11, 2021, 09:08:57 PM
A lot of code lost when I changed to semi retirement, it not really working. Thanks though have saved it again for future use.
Title: Re: Create ARC with TAN-TAN-RAD
Post by: Peter2 on April 12, 2021, 06:06:17 AM
Hi

thanks to all for contributions. Just for testing I add a drawing with 2 examples (red and cyan are existing, yellow it the newly created one. Exact trimming was not done):
- 2 arcs in same direction (of rotation)
- 2 arcs in different directions

For both I failed to work with "fillet command": The first shows "No solution", the second creates the arc in a correct, but unwanted position.
Title: Re: Create ARC with TAN-TAN-RAD
Post by: tombu on April 12, 2021, 08:57:40 AM
Hi

thanks to all for contributions. Just for testing I add a drawing with 2 examples (red and cyan are existing, yellow it the newly created one. Exact trimming was not done):
- 2 arcs in same direction (of rotation)
- 2 arcs in different directions

For both I failed to work with "fillet command": The first shows "No solution", the second creates the arc in a correct, but unwanted position.
An arc with a radius of 10 joins the two for the first exactly. It's probably not working to enough precision for fillet to provide the solution.
What's wrong with the second one?
Title: Re: Create ARC with TAN-TAN-RAD
Post by: kirby on April 12, 2021, 10:25:46 AM
Hi

My routine only does the case of a larger radius transition arc between 2 other arcs all with the same direction of curvature (BigAl referred to as 'C' transition, we call it a 3 centred compound curve in Canada.  There are 2 versions, large transition radius which my routine solves or small transition radius.  Have another solver for the small transition radius case, but it is not generic.

We use a 3 centred compound curves in pavement geometry to avoid spirals for larger intersection curb returns, e.g. 50-25-50m or 70-35-70m but having the middle curve offset by a distance.  These can be solved by simple offset geometry, since the larger 'outside' radii almost always transition to a line (aka tangent) segment.

If transition radius is smaller than one or either of the original arcs, then the centre point of the transition arc will lie on the radials.  Solving the general case could be done by iteration and numerical methods (e.g. bisection method); I don't think this can be directly solved by geometry (at least not with my 35 years out-of-date engineering education).   Need some thinking time for  this.

Circle TTR as suggested by Tombu can be used to do the 'W' transition, it seems to always default to this.

S transition with transition arc having same direction as one of the original arcs is a hybrid.  BigAl is right, you would need to specify the shape of transition vs. solving all possible cases.

(Note most of my code is 25+ years old, so did everything the 'hard' geometry way pre VL.  But not sure why Autodesk/AutoLisp would include an 'inters' command for line-line intersections but nothing for built in for other primitives line-circle or circle-circle intersections, or line-plane, plane-plane, etc.  Now moot with VL intersectwith methods).
Title: Re: Create ARC with TAN-TAN-RAD
Post by: kirby on April 12, 2021, 02:20:29 PM
Update that handles the C curve option (all arcs in same direction).

Hopefully can solve the S curve option and add some commentary/feedback on which transition of radii will or will not work, after another lunchtime or two.

Command is 'AAT'

New routine 'ArcRay' added that can help visualize the radials.  Transition arc will have centre point on the circle at endpoints of these radials.
Title: Re: Create ARC with TAN-TAN-RAD
Post by: BIGAL on April 12, 2021, 11:20:20 PM
The C W S was just random idea for using with Initget. Bit shorter than 3CCCIC  :2funny:

The solution used by the old software was to pick a approximate center point for the new arc so implying a direction for the arc.
Title: Re: Create ARC with TAN-TAN-RAD
Post by: kirby on April 16, 2021, 02:32:10 PM
Hi

I think I might have it figured out after 3 lunchbreaks (aka think-breaks).

Testing Routine 'ArcRay' simply draws radial lines (projections from centre point to arc) at a given transition radius length along the arc at small degree increments.

Since you have 2 arcs (or circles) that you want to draw a transition arc between, you will have 4 circles total (2 inside and 2 outside for each).  The intersection points of the circles will be the potential centre points of your transition arc.  2 circles can have 0, 1 of 2 points of intersection, based on the position of the circles w.r.t. each other.  Testing routine 'TestCCI' will show these intersections.  With 4 circles, you can have between 0 and 8 potential transition arcs.

Main routine 'ArcArcTrans' or shortcut 'AAT' uses the above to calculate each transition arc.  My original 20+ year old routine simply used the transition arc with the midpoint closest the the midpoint between the selection points of both original arcs, but this can return one of the arcs that you don't want.  The updated routine cycles through each of the transition arcs, draw them (with optional radials from centre point) and ask the user if they want to keep or discard.  I tried to come up with a new method of identifying the best transition arc, but sometimes there are a few valid options so just deleted this work in progress.

Note that for compound curves (curves in the same direction, C-Curves in BagAl's parlance, e.g. nn vs. nu or un, or Inside+Inside circle intersection), there is a defininte minimum and maximum transition radius that will work and these relate to the smallest and largest radii of the original arcs and the distance between the arc centre points.  For reverse curves (curves in opposite directions, S-curves, e.g. nu and un), there is a lower bound on the transition radius related to the smallest radius of the original arcs but no upper limit.  Alternate would be to do something like BigAl remembered and select an arc based on a selection point closest to the arc centre point.

Input can be ARC or CIRCLE entities only; I didn't want to deal with the complications of CW polyarc segments until I had something working.

All routines set an undo point.  Just use 'Undo' 'Back' to reset.

Outcome showing the resultant transition arcs for Peter's 2 cases are shown on the second image below.  Not the most elegant tool and (optionally) leaves a lot of messy circles to help the user understand the situation, etc. but it seems to work for a number of different combinations of arcs.  Please let me know if there are any problems.

Cheers!