|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: 2001-11
Posts: 5
![]() |
Does anyone have a routine that measures the shortest distance between 3D planes ?
There doesn't seems to be any AutoCAD 2002 command for it. |
|
|
|
|
|
#2 |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
If you set either plane to be the xy-plane of a UCS, then the z-coordinate of any point on the other plane is the distance between the planes...
It isn't really the "shortest" distance... It's the "distance". Your question is only valid if the planes are parallel. Otherwise, they intersect, and the shortest distance between them is 0. I don't know if this helps you or not. What exactly are you trying to do?
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) Last edited by sinc : 2004-07-27 at 04:05 AM. |
|
|
|
|
|
#3 |
|
Vice President / Director
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I assume that you are not considering infinite planes but finite plane surfaces like 3dfaces.
Although I don't have the solution as code, I could make some suggestions as to how to solve this puzzle. First each surface has a normal that is perpendicular to its face. Well you have to figure out what that is. Check your matrix mathmatics for formulas to figure those out. I would then create a series of conditionals that would use the normal as a vector and place them at each vertice of each 3dface and then figure out how to find the distance to the intersection of that vector to the other surface. Again I would use matrix math to do that. Whichever is shorter is the closest distance. Peter Jamtgaard |
|
|
|
|
|
#4 |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
AutoCAD has routines that return the normal of an object and return the intersection of a plane and a line (the later is in the cal routine), but that will only work if one of the 3D faces is oriented so that the normal even hits the other 3D face... The shortest distance might be a non-normal vector from a corner of one 3D face to a corner of the other, or corner to a point on the other 3D face, or even something like a point on the edge of one 3D face to a point on the edge of the other 3D face.
I'm not sure what the easiest way of approaching it would be.
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) Last edited by sinc : 2004-07-27 at 03:49 PM. |
|
|
|
|
|
#5 |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I'm thinking maybe of drawing a polyline around the edge of each 3D face. Then from each vertex of the first 3D face, find the distance to the closest point on the polyline around the second 3D face using vlax-curve-getClosestPointTo. Repeat, using the vertices of the second 3D face and the polyline around the first 3D face. The shortest distance you find will be the shortest distance between in all cases except when the shortest distance is from the corner of one 3D face to a point on the surface of the other, or the case when the closest distance is from a point on one edge to a point on the other edge...
Now, how best to detect those cases?
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) |
|
|
|
|
|
#6 |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
How about the following pseudo-code:
Code:
<draw polylines (p1, p2) around each face (f1, f2)> <get shortest distance from each vertex of p1 to p2 using vlax-curve-getClosestPointTo> <get shortest distance from midpoint of each segment of p1 to p2 similarly> <repeat last two steps for p2 to p1> <if> <shortest distance found above is from a corner, you found it> <else if> <shortest distance found above is from a midpoint, then:><if> <two and only two opposite sides have shorter distances from the midpoint than from either adjacent vertex, then shortest distance is from edge to edge; in this case the shortest distance is between [the point you found on p2 that's closest to p1] and [the point you found on p1 that's closest to p2])> <else> <shortest distance vector is normal to the other plane and hits somewhere on its surface; figure it using cal to locate the intersection of a line and a plane> <endif><endif>
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) |
|
|
|
|
|
#7 |
|
Member
Join Date: 2001-11
Posts: 5
![]() |
Peter is correct that I am working with finite plane surfaces using solids in most cases.
His suggestion is probably the best way of solving this puzzle. What I have been trying to do is to find the minimum clearances between existing and new structures. Finding out where it clashes is easy. Finding out where the minimum clearance are is more tricky and very time consuming. Looks like this is a big job to create this routine. Have to give this a miss as I have a short time frame to complete this 3D project I am working on. Thanks for the hints guys. |
|
|
|
|
|
#8 |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Can't that be done with simple elevation comparisons?
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) |
|
|
|
|
|
#9 | |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
Simply finding the distance between a point and a plane is not a problem. If you're working with finite, planar surfaces then it would suffice to check the vertices because - if the surface planes are not parallel - one of the vertices will always describe the shortest distance between the surfaces. Of course, if it's required that projected vertices of one surface are located within the other surface - and project edges onto the surface - then it might be a little more work. As Richard points out, it's already part of the CAL program. But here's a purely mathematical approach to find the distance between a point and a plane. If you're working with planar 3Dfaces then simply extract all 3 or 4 vertices and get the minimum distance from those of all points to the plane of the other surface (if 4 vertices then have in mind that a 3DFace can describe two planes). The function to use or modify is getDistToPlane. The others are utility functions. Code:
(defun getDistToPlane (/ p0 p1 p2 p3 dist norm)
;; getting user input. This could easily be changed in order
;; to receive a plane and a point, e.g. a vertice to check
(cond ((and (setq p2 (getpoint "\nOrigin: "))
(setq p1 (getpoint p2 "\nFirst axis direction: "))
(setq p3 (getpoint p2 "\nSecond axis direction: "))
(setq p0 (getpoint "\nPick point: "))
)
;; transform all points to WCS
(mapcar (function (lambda (p) (set p (trans (eval p) 1 0))))
'(p1 p2 p3 p0)
)
;; find normal vector to plane p1-p2-p3
;; and distance from point p0 to plane
(setq norm (V3Normalize (V3Cross (V3Sub p2 p1) (V3Sub p3 p1)))
dist (V3Dot norm (V3Sub p0 p1))
)
(abs dist)
)
)
)
;;; Return the cross product, vec1 cross vec2
(defun V3Cross (vec1 vec2)
(list (- (* (cadr vec1) (caddr vec2)) (* (caddr vec1) (cadr vec2)))
(- (* (caddr vec1) (car vec2)) (* (car vec1) (caddr vec2)))
(- (* (car vec1) (cadr vec2)) (* (cadr vec1) (car vec2))))
)
;;; Return the dot product of vectors vec1 and vec2
(defun V3Dot (v1 v2)
(apply '+ (mapcar '* v1 v2))
)
;;; Return vector difference vec1-vec2 (notice sequence)
(defun V3Sub (vec1 vec2)
(mapcar '- vec1 vec2)
)
;;; Returns squared length of input vector
(defun V3SquaredLength (vec / expt2)
(defun expt2 (a)
(* a a)
)
(apply '+ (mapcar 'expt2 vec))
)
;;; Returns length of input vector
(defun V3Length (vec)
(sqrt (V3SquaredLength vec))
)
;;; Normalizes the input vector and returns it
(defun V3Normalize (vec / len)
(if (/= (setq len (V3Length vec)) 0.0)
(mapcar (function (lambda (a) (/ a len))) vec)
vec
)
)
|
|
|
|
|
|
|
#10 | |
|
AUGI Addict
Join Date: 2004-02
Location: Colorado
Posts: 1,531
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
That's why I have all the "check midpoints" rigamarole in the pseudocode above. All this may be moot, though; if the problem is really to find the CLEARANCE between objects, that's a different problem that might have a simpler solution...
__________________
-- Sinc Civil-3D/Map 2009 http://www.ejsurveying.com http://www.quuxsoft.com (Sincpac-C3D) Last edited by sinc : 2004-07-28 at 09:39 PM. |
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Point at some distance between 2 points - best practice? | KevinBarnett | VBA | 0 | 2004-07-09 07:47 AM |
| Locking Circles and reference planes | Carl | Revit Architecture - General | 6 | 2004-06-16 04:20 PM |
| Psycho reference planes? | Les Therrien | Revit Architecture - General | 10 | 2004-03-15 05:01 PM |
| Reference Planes and Views on Sheets | JamesVan | Revit Architecture - General | 5 | 2003-08-08 03:38 PM |
| work planes cant be ref planes?? | Martin P | Revit Architecture - General | 2 | 2003-06-10 01:25 PM |