Author Topic: Calculating a point defining a line  (Read 5167 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Calculating a point defining a line
« on: March 13, 2007, 10:46:51 AM »
I have a unique situation where I need to calculate programmatically the point as indicated in the picture below. The known dimensions, points, and angles are shown as "known" or a value. The shape is subject to change at any time with the exception of the relationship of the shortest known length line to the top line. The indicated angle will always be 90 degrees.

I need to be able to calculate the final point, in lisp, without resorting to drawing temporary objects, since the operation may take place on drawings that are not open in the editing window.

I can do it really easily by drawing a circle and then a line tangent to the circle, but that requires manually editing the drawings.
Since I am having a difficult time with calculus this morning, I thought some kind soul would help me with the mathematics so I can tranfer it to lisp.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Calculating a point defining a line
« Reply #1 on: March 13, 2007, 11:08:12 AM »
Hum, I don't think you have enough information to calculate it. <I have been know to be mistaken though> 8-)
If you don't have the angle of the angled line, no can do.
Could you use vlax-curve-getClosestPointTo ?
Using inters might be doable too, but you need the line entity for both.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Calculating a point defining a line
« Reply #2 on: March 13, 2007, 11:16:46 AM »
Hum, I don't think you have enough information to calculate it. <I have been know to be mistaken though> 8-)
If you don't have the angle of the angled line, no can do.
Could you use vlax-curve-getClosestPointTo ?
Using inters might be doable too, but you need the line entity for both.
You don't need the line, you only need the points of the line to pass to inters.  But I'm with you about the amount of information.  You have a complete 360 degrees the small line can be.  You need one of the unknow angles.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Calculating a point defining a line
« Reply #3 on: March 13, 2007, 11:21:20 AM »
Well, obviously that isn't the answer I was hoping for .... I have a few ideas I am playing with at the moment ... perhaps ...

how would this work ...

I know the length of the shortest line and the distance associated with 2 known points ... this distance (my hypotenuse) and the side (shortest line) can be mathematically calculated to determine the length of the unknown line ... now I only need to determine the angle so all of the points close ...

I'll be back
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Josh Nieman

  • Guest
Re: Calculating a point defining a line
« Reply #4 on: March 13, 2007, 11:24:03 AM »
I think there is enough information to get it... the key is in the 90d relation of the short chord and the length of it... picturing the unconstrained lines moving around, I can't see them moving, while keeping that short chord at 90 AND at a given length at the same time.  I'll have to work this out on paper though.

I love problems like these :)

Arizona

  • Guest
Re: Calculating a point defining a line
« Reply #5 on: March 13, 2007, 11:26:22 AM »
Trig Functions: The Functions
  

sine(q) = opp/hyp
cosine(q) = adj/hyp
tangent(q) = opp/adj
cotangent(q) = adj/opp
cosecant(q) = hyp/opp
secant(q) = hyp/adj



T.Willey

  • Needs a day job
  • Posts: 5251
Re: Calculating a point defining a line
« Reply #6 on: March 13, 2007, 11:38:42 AM »
I know the length of the shortest line and the distance associated with 2 known points ... this distance (my hypotenuse) and the side (shortest line) can be mathematically calculated to determine the length of the unknown line ... now I only need to determine the angle so all of the points close ...
I think you are on the right path with this.  Glad my thinking was wrong.  Must be too early here on the west coast for me to be thinking.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

uncoolperson

  • Guest
Re: Calculating a point defining a line
« Reply #7 on: March 13, 2007, 11:41:13 AM »
ehhh...
Quote
To get the equation of the tangent to a circle from a point not on the circle:
You must use the perpindicular distance formula (the perpindicular distance from the tangent to the centre of the circle is equal to the radius). The tangent has the equation
y - y1 = m(x - x 1). First get this equation into the form: ax + by + c = 0 using the given point (x1,y1) as one point on the line. If you put this equation into the perpindicular distance formula, with the centre of the circle as the point and make it equal the radius, you should be able to calculate two values for m (the slope).
Putting these values back into the equation:
y - y1 = m(x - x 1), you get two line equations, one for each tangent.


http://www.netsoc.tcd.ie/~jgilbert/maths_site/applets/circles/tangents_to_circles.html

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Calculating a point defining a line
« Reply #8 on: March 13, 2007, 11:51:37 AM »
Maybe this?
I hate it when I'm wrong. Opened my mouth too soon. :oops:
<EDIT: 1st picture was not quite right>
« Last Edit: March 13, 2007, 12:02:46 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VVA

  • Newt
  • Posts: 166
Re: Calculating a point defining a line
« Reply #9 on: March 13, 2007, 12:02:42 PM »
Code: [Select]
(setq P2 (getpoint "\nPoint P2: "))
(setq P4 (getpoint "\nPoint P4: "))
(setq distance-P2P3 (getdist "\nDistance P2-P3:"))
(setq a distance-P2P3)
(setq c (distance P2 P4))
(setq b (sqrt (- (* c c)(* a a))))
(setq tan_alfa (/ b a))
(setq alfa (atan tan_alfa))
(setq ang (angle P2 P4))
(setq new_ang (+ ang alfa))
(setq P3 (polar P2 new_ang a))

Arizona

  • Guest
Re: Calculating a point defining a line
« Reply #10 on: March 13, 2007, 12:12:02 PM »
If you have one side (a) and the hypoteneus (c) then it should be simple to get the last line, thereby getting the angle.

a^2 + b^2 = c^2
Solve for b.


Josh Nieman

  • Guest
Re: Calculating a point defining a line
« Reply #11 on: March 13, 2007, 12:14:07 PM »
man... i made mine way harder on myself than I needed to.  after seeing how ya'll did it I'm not even showing my work lol...

that's why I like this stuff though... learning new ways of looking at things that can be approached a hundred ways and finding a simpler one.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Calculating a point defining a line
« Reply #12 on: March 13, 2007, 12:14:27 PM »
Code: [Select]
(defun test (p1 p2 d1 / B D2 DD)
  (if (< (setq p2(mapcar '/ (mapcar '+ p1 p2)(list 2 2))
               d2 (distance p1 p2)) (+ d1 d2))
    (progn
      (setq
        dd (* d1 d1)
        b  (/ dd (* 2 d2))
      ) ;_  setq
      (polar p1 (+ (angle p1 p2) (angle '(0 0) (list b (sqrt (abs(- dd (* b b))))))) d1)
    ) ;_  progn
  ) ;_  if
)
« Last Edit: March 13, 2007, 12:45:17 PM by ElpanovEvgeniy »

uncoolperson

  • Guest
Re: Calculating a point defining a line
« Reply #13 on: March 13, 2007, 12:19:27 PM »
man... i made mine way harder on myself than I needed to.  after seeing how ya'll did it I'm not even showing my work lol...

that's my approach today...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Calculating a point defining a line
« Reply #14 on: March 13, 2007, 01:03:25 PM »
Here is my code & test routine

Code: [Select]
(defun getPx (L0 L1 L2 L4)
  (defun asin (z /)
    (atan z (sqrt (- 1.0 (* z z))))
  )
  (setq L3 (- L2 L1)
        L5 (sqrt (+ (* L3 L3) (* L4 L4)))
        A2 (- (/ pi 2.) (asin (/ L0 L5)))
  )
)


(defun c:test ()
  (setq p1 (getpoint "\nPick point P1"))
  (setq L0 (getdist p1 "\nDistance L0 ?"))
  (setq L1 (getdist p1 "\nDistance L1 ?"))
  (setq L4 (getdist (getpoint "\nDistance L4 ?")))
  (setq L2 (getdist (getpoint "\nDistance L2 ?")))

  (command ".point"
           "_non"
           (polar P1 (+ (getPx L0 L1 L2 L4) (atan (/ L3 L4))) L0)
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.