Lisp Development

(1/1)

montyLalor:
Hi all,

My lisp knowledge is very limited. However, my imagination is immense, so I need help with bridging this divide.

I would like to be able to select a line and use it's length in a specific calculation to determine the radius of a circle that is to drawn by the routine at the line's end point (not the start point).

The calculation is as follows, where R=circle radius L=line length 45=constant that will change:

R = sqrt ( (2 x 45 x L) - (L²) )

The UCS will be pre-selected, so no change to the coordinate system is required in the routine.

Here's hoping this is a mere walk in the park for Those Who Know.

kdub:
Luke,

The 'best' thing to do is to take it in small bites .. . as my brother would say ; 'like eating an elephant'

Bookmark the pages for math functions and basics from the AutoLisp help file.
work through something like this  (or pick out the bones of it that you need).
http://www.jefferypsanders.com/autolisptut.html

start in the middle
assign the value of L to a variable
calculate ( 2 * 45 * L)
calculate L*L
subtract one from the other
apply the sqrt function to the result.

on the way :
pay attention to parenthesis , they're important
practice, be patient, practice, practice

Regards
and good fortune

just looking at that calculation :
you have a good chance the result will be a negative in some cases , and I have difficulty visualising a negative radius . . .

montyLalor:
Firstly, a small confession: the "45" will actually be 45000. I messed up with the metres vs millimetres thing, I'm embarrassed to say.

So, yeah, the number won't be negative. The equation can fall over, but in the use cases I will be utilising, it will more often look like this:

Where:
Line length (height) = L (magenta)
Circle radius = R (pale yellow)
Known arc radius = 45000 (green)

Essentially, it's an equation that determines the distance between a known-radius arc's 6 o'clock quadrant point and a line, based on the line's length (or height if you take the image's orientation into account). If you have a longer L length (height) you have a greater R value (up until the R = 45000, in this example, beyond that the equation falls over somewhat).

dexus:
I tried to understand what you are trying to find.
I'm not 100% sure this is what you are looking for..
If you offset by the given radius perpendicular to the line form its starting point.
And draw a circle with the given radius with the endpoint of the line as its center.
The intersection will be the centerpoint of the Arc you are looking for.
But the x position of that starting point is I believe the answer to your question.

Not sure yet what the equation will be, but should be doable like this.

Edit:
Here you can find some calculations for the intersection: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/intersection-between-line-and-circle/td-p/831902
I also just realized you get the same result if instead of an offset-line you move the center to (radius - line length) above the endpoint.

montyLalor:
Forgive me for not explaining the formula properly at the start.

Lets start my explanation of it again: this time I'll swap the variable for the Known Radius to "K" for additional clarity.

Starting with 2D:
The formula simply calculates a geometric value. It calculates the distance between the lowest point of a vertical line ( "L" in green ) and the 6 o'clock quadrant of the Known Radius circle when the top of the green line "L" ends on the Known Radius circle. With the Known Radius circle value staying constant, as the green line moves further from the 6 o'clock quadrant point, the value or R increases, up until R = K.

Moving to 3D:
My previous image was trying to portray what the image below shows: the circle calculated, with radius "R", from the Known Radius circle "K" value and the line "L" length inputted into the formula.

Note: The dimensions are in millimetres, so the discrepancy of 0.0001mm can be ignored.

So I'm looking for a way to be able to have a lisp routine prompt the user to select the line "L", store it's length, store it's end point coordinates (which will always be the it's lowest point, co-planar with the 6 o'clock quadrant point of the Known Radius circle) and draw a circle with the calculated radius from the formula.

To say I'm lost with how to implement this in autolisp is a big understatement. Would anyone like to do it and be paid for their expertise?