Jump to content

3d plane and intersecting line


Guest Jreez

Recommended Posts

Guest Jreez

I have a plane defined from ucs-world points: (1,1,0),(3.6,2,1),2.2,3.6,2) .

It is intersected by the line defined by ucs-worlds points: (1.6,3.2,0.2) and(2.8,1.4,1.8 ).

 

Im having trouble trying to manipulate the UCS in order to find the location of the piercing point, the true length of the line and slope.

 

Its been a while since we went over this and its not coming back to me...your help is much appreciated :)

Link to comment
Share on other sites

Hi Jreez, welcome to CTF!

 

Your situation really made me ponder as I have never done anything like that before.

 

I don't know what you are working on but I think I found a way (or at least my way) to do it.

 

Type UCS, then New, then 3 for 3point. Just pick the three corners of your plane to make the UCS aligned to it.

 

Next, we need to rotate the UCS 90

Link to comment
Share on other sites

AutoCAD comes with a built in function for that. Draw first the line and also draw two lines to define the plane (you have 3 points for the plane, so draw lines from a point to the other two). How do you need to use the intersection? Probable you wish to place a point or start a line from or something. So start that command (POINT or LINE) and when AutoCAD prompts you for the point, enter

'CAL

ILP(END,END,END,END,END)

The cursor should change in a square. Pick first the two endpoints of the line, after that the 3 endpoints of the lines defining the plane.

It is not so complicated as it sounds; ILP means Intersection between Line and Plane and it needs 5 arguments: the first two points to specify the line and more 3 points to determine the plane.

Link to comment
Share on other sites

If you full ACAD, this lisp will find the intesection point. You would have to set the UCS ( 3P ) prior to calling the function.

 

;;;INTERSECTION POINT OF A LINE AND THE CURRENT CS
;;;ARG -> 2 WCS Line Points
;;;RET -> 'LIST (point) or nil
(defun int_line_plane (p1 p2 / tp1 tp2 ip)

 (setq tp1 (trans p1 0 1)
       tp2 (trans p2 0 1))

 (if (setq ip
       (inters tp1 tp2
         (list (car tp1) (cadr tp1) 0)
         (list (car tp2) (cadr tp2) 0) nil))
      (setq ip (trans ip 1 0)))

 ip)

Remember to reset the UCS afterwards. -David

Link to comment
Share on other sites

  • 7 years later...
  • 1 month later...

Here’s a method using vector math and Visual LISP to find the intersection of a line and a plane in 3D space.

 

Assume the plane is defined by three points, P1, P2, and P3. The line is defined by two points L1, and L2. The first step is to define the plane by using a normal vector N (a line perpendicular to the plane) and a point on the plane (either P1, P2, or P3 will do). Using a cross product we can define the normal as:

 

N = (P2-P1) cross (P3- p1)

 

We will use a parametric definition for the line. That is, a point on the line P, is defined by two points on the line and an independent variable t.

 

P = (1-t)*L1 + t*L2

 

Given a value for t and the coordinates of L1 and L2 we can find a point on the line that passes through L1 and L2. To find that value of t where the line intersects the plane (we will call it tk) we can use the following expression:

 

tk = - ( N1 dot (L1 – P1)) / (N dot (L2 – L1))

where dot is the dot product of two vectors.

 

Knowing tk, the point of intersection of the line and the plane PInt is:

 

PInt = (1-tk) * L1 + tk * L2 or Pint = L1 – tk*(L2-L1)

 

Here’s the code in VisualLISP with functions to compute the dot and cross product of two vectors.

 

(defun c:PlaneLineIntersect (/)

(setq osn (getvar "osmode")) ; save current OSNAP settings

(command "ucs" "") ; change to the WCS

(setvar "pdmode" 35) ; set point style to something you can see

(setq P1 (getpoint "\n Enter 1st point on plane")

P2 (getpoint "\n Enter 2nd point on plane")

P3 (getpoint "\n Enter 3rd point on plane")

L1 (getpoint "\n Enter point on one end of line")

L2 (getpoint "\n Enter point on other end of line")

)

; Calculate plane normal N

(setq N (cross (mapcar '- P2 P1) (mapcar '- P3 p1)))

; calculate tk

(setq tk (- (/ (dot N (mapcar '- L1 P1)) (dot N (mapcar '- L2 L1)))))

; the point of intersection is

(setq PInt (mapcar '+ L1 (mapcar '* (mapcar '- L2 L1) (list tk tk tk))))

; draw a line from L1 to point of intersection

(setvar "osmode" 0) ; first turn off OSNAP

(command "line" L1 PInt "")

(command "point" PInt "")

(setvar "osmode" osn) ; set osnap back to original setting

)

;;; Compute the dot product of 2 vectors a and b

(defun dot (a b / dd)

(setq dd (mapcar '* a b))

(setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd)))

) ;end of dot

;;; Compute the cross product of 2 vectors

(defun cross (a b / crs)

(setq crs (list

(- (* (nth 1 a) (nth 2 b))

(* (nth 1 b) (nth 2 a))

)

(- (* (nth 0 b) (nth 2 a))

(* (nth 0 a) (nth 2 b))

)

(- (* (nth 0 a) (nth 1 b))

(* (nth 0 b) (nth 1 a))

)

)

)

)

Link to comment
Share on other sites

Autodesk Inventor has tools for this.

Not limited to plane - could be pierce point of any vector through any organic surface.

Pierce Point.jpg

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...