Author Topic: Intersection Between 2 Lines using math  (Read 1608 times)

0 Members and 1 Guest are viewing this topic.

LSElite

  • Newt
  • Posts: 65
Intersection Between 2 Lines using math
« on: November 20, 2015, 07:29:02 PM »
Hey All

I am trying to find the intersection point between to lines.
The lines are represented by 2 points
line1 = (x1, y1, z1) (x2, y2, z2)
line2 = (x3, y3, z3) (x4, y4, z4)

I am aware I can achieve the desired outcome through the Intersect method.
However I wanted to avoid the unnecessary adding and removing from the database.

I have tried hashing this out through raw math but I keep running into the problem.
Vertical lines do not work for the intersection equation due to the lack of Y intercept.
http://www.mathopenref.com/coordequation.html
Is it possible to inverse the intersection equation to work with x intercepts instead of y?
then I could set up 3 intercept types: x, y and vertical perpendicular.

Any math guru's out there able to shed some light?

To recap, what I am looking for is a function using 2 lines, (p1 p2) (p3 p4), that returns the coordinates of the intersection.
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Intersection Between 2 Lines using math
« Reply #1 on: November 20, 2015, 07:45:28 PM »
The pure Math solutions I've seen are very complicated.

Did you know that the lisp function inters<> does not require objects ?

Code - Auto/Visual Lisp: [Select]
  1. (inters pt1 pt2 pt3 pt4 [onseg])

added:
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A181D474-F817-4550-86E9-87649262FA8A
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LSElite

  • Newt
  • Posts: 65
Re: Intersection Between 2 Lines using math
« Reply #2 on: November 20, 2015, 08:08:12 PM »
Kerry, you sir are a life saver.
That is heaps easier.

I think I figured out the math solution anyway.
Instead of making the Ys equal to find X, you can use the X value of the vertical line since X doesn't change.
It actually makes it significantly easier, haha.  :lol:
Felt like a clown when I realized.
“A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing.”
― George Bernard Shaw

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Intersection Between 2 Lines using math
« Reply #3 on: November 20, 2015, 08:18:44 PM »

Quote
Felt like a clown when I realized.
You'll fit in really well here then ;-D

but seriously,
Sometimes the process of fully writing out the problem ( tell it to the duck ) makes a resolution visible.
... verbalising puts the issues in focus.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.