Author Topic: Bug in vla-IntersectWith (established)  (Read 7838 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Bug in vla-IntersectWith (established)
« Reply #15 on: April 22, 2014, 08:26:51 AM »
Dear Lee,

You code works perfect in the case where (vlax-invoke obj1 'IntersectWith obj2 ExtendOption) does not work.

Excellent !!! But how come this code works and inbuilt INTERSECTWITH function does not work ?

What is the reason for this ? Can you please enlighten us on this ?

Thanks

ymg

  • Guest
Re: Bug in vla-IntersectWith (established)
« Reply #16 on: April 22, 2014, 10:45:08 AM »
Anybody old enough to remember Daniel Piazza' s Sweepline.lsp

In the attachment there is also a greedy algorithm by Reini Urban.

ymg


ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Bug in vla-IntersectWith (established)
« Reply #17 on: April 22, 2014, 02:04:52 PM »
Nice example, ymg... Your posted code inspired me to check how (inters) function work...

My version is also correct... I've compared it and the results were the same...

Code - Auto/Visual Lisp: [Select]
  1. (defun _inters ( p1 p2 p3 p4 f / v^v Coplanar-p Parallel-p x1 x2 x3 x4 y1 y2 y3 y4 z1 z2 z3 z4 xp yp zp p )
  2.  
  3.   (defun v^v ( u v / cda )
  4.     (defun cda ( p ) (cdr (append p p)))
  5.     (mapcar '- (mapcar '* (cda u) (cdr (cda v))) (mapcar '* (cdr (cda u)) (cda v)) '(0.0 0.0 0.0))
  6.   )
  7.  
  8.   (defun Coplanar-p ( p1 p2 p3 p4 )
  9.     (
  10.       (lambda ( n1 n2 )
  11.         (equal (v^v n1 n2) '(0.0 0.0 0.0) 1e-8)
  12.       )
  13.       (v^v (mapcar '- p1 p2) (mapcar '- p1 p3))
  14.       (v^v (mapcar '- p1 p2) (mapcar '- p1 p4))
  15.     )
  16.   )
  17.  
  18.   (defun Parallel-p ( p1 p2 p3 p4 )
  19.     (equal (v^v (mapcar '- p1 p2) (mapcar '- p3 p4)) '(0.0 0.0 0.0) 1e-8)
  20.   )
  21.  
  22.   (setq x1 (car p1)
  23.         x2 (car p2)
  24.         x3 (car p3)
  25.         x4 (car p4)
  26.         y1 (cadr p1)
  27.         y2 (cadr p2)
  28.         y3 (cadr p3)
  29.         y4 (cadr p4)
  30.         z1 (caddr p1)
  31.         z2 (caddr p2)
  32.         z3 (caddr p3)
  33.         z4 (caddr p4)
  34.   )
  35.   (setq xp (/ (- (* (- x4 x3) (- (* y1 x2) (* y2 x1))) (* (- x2 x1) (- (* y3 x4) (* y4 x3)))) (- (* (- x2 x1) (- y4 y3)) (* (- y2 y1) (- x4 x3))))
  36.         yp (+ (* xp (/ (- y2 y1) (- x2 x1))) (/ (- (* y1 x2) (* y2 x1)) (- x2 x1)))
  37.         zp (+ (* xp (/ (- z2 z1) (- x2 x1))) (/ (- (* z1 x2) (* z2 x1)) (- x2 x1)))
  38.         p (list xp yp zp)
  39.   )
  40.  
  41.   (if (Coplanar-p p1 p2 p3 p4)
  42.     (if (not (Parallel-p p1 p2 p3 p4))
  43.       (if f
  44.         (if (equal (+ (distance p1 p) (distance p p2)) (distance p1 p2) 1e-8)
  45.             p
  46.             nil
  47.         )
  48.         p
  49.       )
  50.       nil
  51.     )
  52.     nil
  53.   )
  54.  
  55. )
  56.  
« Last Edit: April 22, 2014, 07:24:18 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube