Author Topic: Lisp Development  (Read 3182 times)

0 Members and 1 Guest are viewing this topic.

montyLalor

  • Mosquito
  • Posts: 11
  • Native of Lothal
Lisp Development
« on: November 27, 2022, 11:11:58 PM »
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.

Thank you in advance.
Learnt AutoCAD when it was V12 for DOS...
Working it full time for about a decade...   ...currently using 2020...
Why does it seem like my knowledge of this program maneuvers with the eloquence of a fiery wall of disintegrating fuselage?

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2121
  • class keyThumper<T>:ILazy<T>
Re: Lisp Development
« Reply #1 on: November 28, 2022, 01:08:36 AM »
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

added:
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 . . .
« Last Edit: November 28, 2022, 01:17:41 AM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

montyLalor

  • Mosquito
  • Posts: 11
  • Native of Lothal
Re: Lisp Development
« Reply #2 on: November 28, 2022, 05:28:06 AM »
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).
Learnt AutoCAD when it was V12 for DOS...
Working it full time for about a decade...   ...currently using 2020...
Why does it seem like my knowledge of this program maneuvers with the eloquence of a fiery wall of disintegrating fuselage?

dexus

  • Newt
  • Posts: 196
Re: Lisp Development
« Reply #3 on: November 28, 2022, 08:18:47 AM »
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.
« Last Edit: November 28, 2022, 08:32:32 AM by dexus »

montyLalor

  • Mosquito
  • Posts: 11
  • Native of Lothal
Re: Lisp Development
« Reply #4 on: December 12, 2022, 08:02:32 AM »
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?
Learnt AutoCAD when it was V12 for DOS...
Working it full time for about a decade...   ...currently using 2020...
Why does it seem like my knowledge of this program maneuvers with the eloquence of a fiery wall of disintegrating fuselage?