Jump to content

How to find the intersection of two lines?


ekko

Recommended Posts

Hello everyone, how can I find the intersection of (spt-ept p1-p3) and (spt-ept-p2-p4), I use (inters spt ept p1 p3 nil) and (inters spt ept p2 p4 nil), when p1 ,2,3,4 points in order, the intersection point can be obtained, if the order is out of order, it will return nil, which seems to need to sort p1,2,3,4, how can I do this? Is there any other way?20220319.png.3a39c6d77a26eefdf67d0d2a98306714.png

Link to comment
Share on other sites

If you make  dummy objects like line p1-p3 then can get the (setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity)) will return the intersection point, then just delete dummy objects. Xline is useful.

Link to comment
Share on other sites

7 hours ago, BIGAL said:

If you make  dummy objects like line p1-p3 then can get the (setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity)) will return the intersection point, then just delete dummy objects. Xline is useful.

202203191.png.9d0fd78cf185ecbaa1939997e7fb9bd9.png

I tried it and found that this is a troublesome method. Looking at the picture, it currently has 3 point tables, and each point table has 4 diagonal points. Create a virtual line first. This is your suggestion. But the 4 points of 1 item in each table, with my current technical level, need to create 4 virtual lines (because I can't judge the direction in the table), to get the intersection point, and then delete the virtual line. These workloads are just to get two intersection points. Assuming that the amount of data in the table is too large, obviously this method is not the best choice. I think (inters spe ept pt1 p2 nil) This method is the easiest, the premise is that you must first judge and find two points in the point table that are perpendicular to spt ept, this is my knowledge blind spot, please help, or suggest better Methods. thanks

Edited by ekko
Link to comment
Share on other sites

 

15 hours ago, ekko said:

if the order is out of order, it will return nil

It should still return a point unless mixing up the order create parallel lines. granted its not the point your looking for.

 

How are these points being defined? That's where the sorting should take place. so then you can use inters to get the correct point.

If its always a rectangle that is horizontal use bounding box

(setq rec (vlax-ename->vla-object (car (entsel "\nPick Rectangle"))))
(vla-getboundingbox rec 'minpt 'maxpt)
(setq P1 (vlax-safearray->list minpt) ;lower left
      P4 (vlax-safearray->list maxpt) ;upper right
      p3 (list (car LL)(cadr UR))
      p2 (list (car UR)(cadr LL))
)

 

Edited by mhupp
  • Thanks 1
Link to comment
Share on other sites

@ekko  The use of inters is not sensitive to the order of the first two points or final two points for defining the two lines.  Be sure to turn off object snap after getting the 4 points!

If the lines are always horizontal and vertical then you do not need inters. Then,

Intersection point x = p3x or p4x

Intersection point y = SPTy or EPTy

  

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...