Skip to content

fix intersection3 (may be optimization problem) #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lisp/Makefile.Linux
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ THREADDEP=mthread_posix.c

# If you don't like optimization, comment out the next line.
OFLAGS=-O2
# armhf does not work with -O2, see https://github.com/euslisp/EusLisp/pull/427
ifneq (,$(findstring armv,$(shell uname -m)))
CFLAGS=-O0
endif

# link-editor's default flags ?-rdynamic
SOFLAGS:= $(LDFLAGS) -shared -Xlinker -build-id
Expand Down
9 changes: 5 additions & 4 deletions lisp/Makefile.LinuxARM
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ else
CPU_OPTIMIZE=-march=armv8-a
ALIGN_FUNCTIONS=-falign-functions=8
ADD_CFLAGS=-fPIC -Darmv8
OFLAGS=-O2
else
CPU_OPTIMIZE=-march=$(MACHINE)
CPU_OPTIMIZE=
ALIGN_FUNCTIONS=-falign-functions=4
ADD_CFLAGS=-fno-stack-protector -fpic
# armhf does not work with -O2, see https://github.com/euslisp/EusLisp/pull/427
ADD_CFLAGS=-fno-stack-protector -fpic -O0
OFLAGS=-O0
endif
GCC3=-DGCC3
endif
Expand Down Expand Up @@ -105,8 +108,6 @@ GLLIB= -L$(ADLIBDIR) -lGLU -lGL -lXext -leusgl
THREADDEP=mthread_posix.c
#THREADDEP=pthreads.c

# If you don't like optimization, comment out the next line.
OFLAGS=-O2

# link-editor's default flags ?-rdynamic
SOFLAGS= -shared -Xlinker -build-id
Expand Down
2 changes: 2 additions & 0 deletions lisp/comp/comp.l
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@
)
(setq *coptflags* (format nil " -O~A" c-optimize))
(setq *coptflags* ""))
#+(and :arm :word-size=32) ;; armhf does not work with -O2, see https://github.com/euslisp/EusLisp/pull/427
(setq *coptflags* " -O0")
(setq *optimize* optimize
*safety* safety
*verbose* verbose)
Expand Down
18 changes: 18 additions & 0 deletions test/geo.l
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
(init-unit-test)

(in-package "GEO")
;; redefined to use normalize-vector defined in irteus(?)
;; this requrie to avoid outer circuit not found in (body+ c1 b d1 c2 d2 c3 d3 c4 d4)
(defun face-normal-vector (vertices)
(let* ((v1 (first vertices)) (v2) (vlist (rest vertices))
(v (float-vector 0 0 0))
Expand Down Expand Up @@ -38,6 +40,22 @@
(assert (eps= (send f :distance (float-vector 200 0 100)) (norm #f(100 100))))
))

;; test intersection3
;; https://github.com/euslisp/jskeus/pull/561
(deftest triangulation-intersection3 ()
(let ((l0 (make-line (float-vector -120.0 -30.0 0.0) (float-vector 15.0 0.0 0.0)))
(l1 (make-line (float-vector -15.0 120.0 0.0) (float-vector -15.0 0.0 0.0)))
res-p res-n)
(setq res-p (geo::line-intersection3 (l0 . pvert) (l0 . nvert) (l1 . pvert) (l1 . nvert) 0.00001)) ;; -> (0.777778 1.05556)
(setq res-n (geo::line-intersection3 (l1 . pvert) (l1 . nvert) (l0 . pvert) (l0 . nvert) 0.00001)) ;; -> (1.05556 0.777778)
(warn ";;; intersection3 (res-p) ~A~%" res-p)
(warn ";;; intersection3 (res-n) ~A~%" res-n)

(assert (eps= (elt res-p 0) (elt res-n 1)))
(assert (eps= (elt res-p 1) (elt res-n 0)))
))


(eval-when (load eval)
(run-all-tests)
(exit))