TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: SOFITO_SOFT on December 23, 2010, 04:39:21 AM
-
Hi all:
For example, from 3 points (not coliniars) of each plane.
Any input is appreciated. :wink:
-
depends ..
In what plane do you want the angle expressed ?
Do you want the angle in the plane of the 3 points ?
or the angle in the current View ?
or the angle when viewed in World plan ?
How are the points defined .. In world ordinates in in relation to the current UCS ?
See what happens here ... ask a question and someone will ask you at least 4 more :)
-
This?
;; Angle Between Planes - Lee Mac 2010
;; Args: p1,p2,p3 - Points on First Plane
;; p4,p5,p6 - Points on Second Plane
(defun AngleBetweenPlanes ( p1 p2 p3 p4 p5 p6 )
(
(lambda ( u v )
(acos (/ (vxv u v) (* (norm u) (norm v))))
)
(v^v (mapcar '- p3 p2) (mapcar '- p2 p1))
(v^v (mapcar '- p6 p5) (mapcar '- p5 p4))
)
)
;; Vector Cross (Wedge) Product - Lee Mac 2010
;; Args: u,v - vectors in R^3
(defun v^v ( u v )
(list
(- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
(- (* (car v) (caddr u)) (* (car u) (caddr v)))
(- (* (car u) (cadr v)) (* (car v) (cadr u)))
)
)
;; Vector Dot Product - Lee Mac 2010
;; Args: u,v - vectors in R^n
(defun vxv ( u v )
(apply '+ (mapcar '* u v))
)
;; Vector Norm - Lee Mac 2010
;; Args: v - vector in R^n
(defun norm ( v )
(sqrt (apply '+ (mapcar '* v v)))
)
;; ArcCosine - Lee Mac 2010
;; Args: -1 <= x <= 1
(defun acos ( x )
(if (<= (abs x) 1.0)
(if (equal x 0.0 1e-8)
(* pi 0.5)
(atan (/ (sqrt (- 1.0 (* x x))) x))
)
)
)
-
Lee, don't have time to play ..
Does that return the Dihedral angle ?
I couldn't see the question intent exactly, but that may be it.
-
Lee, don't have time to play ..
Does that return the Dihedral angle ?
Correct, the angle between the normals :-)
-
Hello:
Lee Marc is known about that question.
His program is perfect. You only need to add a verfificacion for 3 points of each plane (in UCS W) form a plane (not aligned).
A possible improvement is to ensure the 2 planes are the same. What angle are 2 planes overlap? The angle is not 0.0 ... Is Null? is infinite ? is not definided ? :-o Thank you all. :-)
-
You only need to add a verfificacion for 3 points of each plane (in UCS W) form a plane (not aligned).
That is the caller's responsibility :lol:
-
Hello again:
Sorry ... Another second verfificacion: all the 3 points of each plan must be differents, else it cause a division by 0 and the resulting error.
So I added the word "infallible". The "truck" thickens with points taken from who knows where (other progarms / geometrics functions.) Anyway, it's a good basis for a unfailing foolproof function. Thanks again. Health for the swamp people.
-
This subfunction is for the calculation - IMO all error trapping should be in the calling function.
-
soffit,
You will need to check that the 3 points in each plane are colinear (ie not in a straight line)
Then check that the planes are NOT coplanar (ie: that the normal (Z Direction) of one plane is not the same and does not negate the other plane.
Then you can run a routine similar to Lee's.
-
Just to satisfy my curiosity,
How are you collecting these Points ??
-
Hello:
;; Angle Between Planes - Lee Mac 2010
;; Args: p1,p2,p3 - Points on First Plane
;; p4,p5,p6 - Points on Second Plane
;|
- UPPER CASE CODE : ADDEMDUM VERIFICATION GEOMETRY CASES WITH SOLUTION BIZARRE BY SOFITO_SOFT :)
- RETURN :
nil = FAIL DATA... NO 2DPTS OR 3DPTS, CO-LINEAR PTS PLAN, nil PTS, VERY NEAR PTS
0.0 = PARALEL OR OVERLAP PLANS !!! < REVISION
> 0.0 REAL < PI = ONE OF 2 ANGLE INTER PLANS , ANOTER IS PI - RETURN
- PARA PRUEBAS
( ANGLEBETWEENPLANES (G) (G) (G) (G) (G) (G) )
( DEFUN G (/) (GETPOINT) )
- ORIGINAL
(defun AngleBetweenPlanes ( p1 p2 p3 p4 p5 p6 )
(
(lambda ( u v )
(acos (/ (vxv u v) (* (norm u) (norm v))))
)
(v^v (mapcar '- p3 p2) (mapcar '- p2 p1))
(v^v (mapcar '- p6 p5) (mapcar '- p5 p4))
)
)
|;
(defun AngleBetweenPlanes ( p11 p22 p33 p44 p55 p66 /
P1 P2 P3 P4 P5 P6
)
; TOLER ES PUBLICA
( IF ( OR
( NOT TOLER )
( NOT ( NUMBERP TOLER ) )
)
( SETQ TOLER 1E-8 )
)
( IF ( AND
( SETQ P1 (FUERZ_PUNTO3D P11)) ; PRUEBA PUNTOS Y 2D -> 3D (Z=0.0)
( SETQ P2 (FUERZ_PUNTO3D P22))
( SETQ P3 (FUERZ_PUNTO3D P33))
( SETQ P4 (FUERZ_PUNTO3D P44))
( SETQ P5 (FUERZ_PUNTO3D P55))
( SETQ P6 (FUERZ_PUNTO3D P66))
( > (DISTANCE P1 P2) TOLER ) ; PRUEBA DISTINTOS
( > (DISTANCE P2 P3) TOLER )
( > (DISTANCE P4 P5) TOLER )
( > (DISTANCE P5 P6) TOLER )
( COLIN_3PUNTO P1 P2 P3 ) ; PRUEBA EXISTEN INTERS.-> NO CO-LINEALES
( COLIN_3PUNTO P4 P5 P6 )
) ; AND
( ABS
(
(lambda ( u v )
(acos (/ (vxv u v) (* (norm u) (norm v)))) ; <- CODIGO MAGISTRAL !! :)
)
(v^v (mapcar '- p3 p2) (mapcar '- p2 p1)) ; <- CODIGO MAGISTRAL !! :)
(v^v (mapcar '- p6 p5) (mapcar '- p5 p4)) ; <- CODIGO MAGISTRAL !! :)
)
)
) ; IF
) ; DEFUN
(DEFUN ES_PUNTO (PUNTO /
)
(AND (LISTP PUNTO)
( OR
( = 2 (LENGTH PUNTO) )
( = 3 (LENGTH PUNTO) )
)
(APPLY
(FUNCTION AND)
(MAPCAR (FUNCTION NUMBERP) PUNTO)
)
)
)
(DEFUN FUERZ_PUNTO3D (PUNTO /
)
(IF (AND
(LISTP PUNTO)
(ES_PUNTO PUNTO)
)
(IF (CADDR PUNTO)
(LIST (FLOAT (CAR PUNTO)) (FLOAT (CADR PUNTO)) (FLOAT (CADDR PUNTO)))
(LIST (FLOAT (CAR PUNTO)) (FLOAT (CADR PUNTO)) 0.0)
)
)
)
(DEFUN COLIN_3PUNTO (V11 V22 V33 /
V1 V2 V3
)
(IF
(AND
(SETQ V1 (FUERZ_PUNTO3D V11))
(SETQ V2 (FUERZ_PUNTO3D V22))
(SETQ V3 (FUERZ_PUNTO3D V33))
(NOT (EQUAL 0.0 (DISTANCE V1 V2 ) TOLER))
(NOT (EQUAL 0.0 (DISTANCE V1 V3 ) TOLER))
(NOT (EQUAL 0.0 (DISTANCE V2 V3 ) TOLER))
)
(INTERS V1 V2 V1 V3 )
)
)
;; Vector Cross (Wedge) Product - Lee Mac 2010
;; Args: u,v - vectors in R^3
(defun v^v ( u v )
(list
(- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
(- (* (car v) (caddr u)) (* (car u) (caddr v)))
(- (* (car u) (cadr v)) (* (car v) (cadr u)))
)
)
;; Vector Dot Product - Lee Mac 2010
;; Args: u,v - vectors in R^n
(defun vxv ( u v )
(apply '+ (mapcar '* u v))
)
;; Vector Norm - Lee Mac 2010
;; Args: v - vector in R^n
(defun norm ( v )
(sqrt (apply '+ (mapcar '* v v)))
)
;; ArcCosine - Lee Mac 2010
;; Args: -1 <= x <= 1
(defun acos ( x )
(if (<= (abs x) 1.0)
(if (equal x 0.0 1e-8)
(* pi 0.5)
(atan (/ (sqrt (- 1.0 (* x x))) x))
)
)
)
I think that now is almost indestructible. The points are passed to other functions, such as "inters line / plan", "inters cone / line " "interes plan / planXY ", etc. It has given me many problems here. I want to do this in the picture. Thank you all for your interest. :-)
(http://img337.imageshack.us/img337/5544/follonazodebarras2.th.jpg)
-
I have not much practice on this. :lol:
[img=http://img337.imageshack.us/img337/5544/follonazodebarras2.th.jpg] (http://img337.imageshack.us/i/follonazodebarras2.jpg/)
-
Just for fun, try with these planes
(setq p1 '(-1000. 0. 0.)
p2 '(0. 0. 0.)
p3 '(0. 500. 100.)
p4 '(1000. 0. 0.)
p5 '(0. 0. 0.)
p6 '(0. 500. 100.)
)
(setq p1 '(-1000. 200. 0.)
p2 '(0. 0. 0.)
p3 '(0. 500. 100.)
p4 '(1000. 200. 100.)
p5 '(0. 0. 0.)
p6 '(0. 500. 100.)
)
-
Lee, don't have time to play ..
Does that return the Dihedral angle ?
Correct, the angle between the normals :-)
No, The dihedral angle is between faces, not between normals.
-
Lee, don't have time to play ..
Does that return the Dihedral angle ?
Correct, the angle between the normals :-)
No, The dihedral angle is between faces, not between normals.
The angle between the faces and the angle between the normals would be the same (up to sign) since the normals are perpendicular.
http://mathworld.wolfram.com/DihedralAngle.html (http://mathworld.wolfram.com/DihedralAngle.html)
-
Hello:
Kerry: You're an expert in magic numbers? :-o Very goog test !. ACOS is not ready for magic numbers, else only for funky :-P .Thanks.
-
SOFITO_SOFT
Sorry, English is my only language and I don't understand your meaning in the last post..
Just a note on the result you are expecting.
I asked how the data was being collected and you chose not to answer, so ...
I believe that the angle you are returning is useless without having a point of reference ... how do you know if the joint is viewed from the inside or the outside, whether the result is actually truly 15 degrees acute or 105 degrees convex or 165 degrees concave.
That is, I believe you need to provide a reference point to indicate which side of the planes the angle is measures.
In fact, planes are considered boundless, so you may also need to express (or consider) if you are assuming that the planes terminate at their intersection joint.
If the plane selection process is manual and the user has a chance to use his judgement the chance of misinterpretation is minimised somewhat ;
but if you are feeding your program large quantities of plane definition points and basing future decisions on possibly incorrect results I can see a lot of pain in your future.
Regards
Kerry
Picture added :
-
Hello :
Sorry for my Paleolithic English . I only speak Spanish, French, Italian and some Basque. But Yes I've tried to answer:
I think that now is almost indestructible.
>>> The points are passed for other functions, such as "inters line / plan", "inters cone / line " "inters plan / planXY ", etc. <<<<
It has given me many problems here. ....
I explain: ACOS function not solve all cases. When the normal plans are equal and opposite, returns NIL. That's why I said that is only prepared for the "funky" (the easy) and not for "magical combiationes of coordinates", such as those you sent me for testing.
if you are feeding your program large quantities of plane definition points and basing future decisions on possibly incorrect results I can see a lot of pain in your future
<<<<< and I have. :-o
In fact, planes are considered boundless, so you may also need to express (or consider) if you are assuming that the planes terminate at their intersection joint.
<<<<< is a good idea four new implementations, but with those 2 angles I have solved (for now :-o) my case.
Thanks and sorry for the misunderstanding. You are very attentive and patient with me.
Greetings from Madrid (Spain-UE).