Skip to content
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

Henry Baker's contribution of 2013 July #21

Merged
merged 1 commit into from
May 22, 2014
Merged

Henry Baker's contribution of 2013 July #21

merged 1 commit into from
May 22, 2014

Conversation

inabajsk
Copy link
Contributor

replace remove-duplicates and make-body-from-vertices
with Henry Baker's implementation with hash table.

#14

k-okada added a commit that referenced this pull request May 22, 2014
@k-okada k-okada merged commit c155a2f into euslisp:master May 22, 2014
@snozawa
Copy link
Contributor

snozawa commented Jun 11, 2014

This PR seems to break model generating codes, especially in rbrain/xx.l.

For example, this code does not work after this PR: (copied from rbrain/patramodel.l)

(let (bottom-frame
     b
     c1 c2 c3 c4 
     d1 d2 d3 d4
     )
     ;; tekitou
     ;;     (setq bottom-frame (make-cube 600 480 250))
     (setq c1 (make-cube 650 20.4 20)
       c2 (make-cube 150 20.5 20)
       c3 (make-cube 600 20.4 20)
       c4 (make-cube 320 20.2 20)
       b (make-cube 300 480 250)
       )

     (send c1 :rotate (deg2rad -39) :y)
     (send c2 :rotate (deg2rad 36) :y)
     (send c3 :rotate (deg2rad -54) :y)
     (send c4 :rotate (deg2rad 31) :y)
     (send b :rotate (deg2rad -45) :y)


     (send c1 :translate #f(-49.0 0 86) :world)
     (send c2 :translate #f(250.0 0 248) :world)
     (send c3 :translate #f(129.0 0 -35.0) :world)
     (send c4 :translate #f(-175.0 0 -200.0) :world)
     (send b :translate #f(-50.0 0 -50.0) :world)
     (setq d1 (copy-object c1)
       d2 (copy-object c2)
       d3 (copy-object c3)
       d4 (copy-object c4))

     (send-all (list c1 c2 c3 c4) :translate #f(0 225 0) :world)
     (send-all (list d1 d2 d3 d4) :translate #f(0 -225 0) :world)
     (setq bottom-frame (body+ c1 b d1 c2 d2 c3 d3 c4 d4)) ;; <= here, body+ fails
     (setf (get bottom-frame :face-color) :dimgray)
     (setf (get bottom-frame :weight) 100)
     bottom-frame
     )

@snozawa snozawa mentioned this pull request Jun 11, 2014
@k-okada
Copy link
Member

k-okada commented Jun 11, 2014

good catch, let add test code.

On Wed, Jun 11, 2014 at 4:14 PM, Shunichi Nozawa [email protected]
wrote:

This PR seems to break model generating codes, especially in rbrain/xx.l.

For example, this code does not work after this PR: (copied from
rbrain/patramodel.l)

(let (bottom-frame
b
c1 c2 c3 c4
d1 d2 d3 d4
)
;; tekitou
;; (setq bottom-frame (make-cube 600 480 250))
(setq c1 (make-cube 650 20.4 20)
c2 (make-cube 150 20.5 20)
c3 (make-cube 600 20.4 20)
c4 (make-cube 320 20.2 20)
b (make-cube 300 480 250)
)

 (send c1 :rotate (deg2rad -39) :y)
 (send c2 :rotate (deg2rad 36) :y)
 (send c3 :rotate (deg2rad -54) :y)
 (send c4 :rotate (deg2rad 31) :y)
 (send b :rotate (deg2rad -45) :y)


 (send c1 :translate #f(-49.0 0 86) :world)
 (send c2 :translate #f(250.0 0 248) :world)
 (send c3 :translate #f(129.0 0 -35.0) :world)
 (send c4 :translate #f(-175.0 0 -200.0) :world)
 (send b :translate #f(-50.0 0 -50.0) :world)
 (setq d1 (copy-object c1)
   d2 (copy-object c2)
   d3 (copy-object c3)
   d4 (copy-object c4))

 (send-all (list c1 c2 c3 c4) :translate #f(0 225 0) :world)
 (send-all (list d1 d2 d3 d4) :translate #f(0 -225 0) :world)
 (setq bottom-frame (body+ c1 b d1 c2 d2 c3 d3 c4 d4)) ;; <= here, body+ fails
 (setf (get bottom-frame :face-color) :dimgray)
 (setf (get bottom-frame :weight) 100)
 bottom-frame
 )


Reply to this email directly or view it on GitHub
#21 (comment).

@snozawa
Copy link
Contributor

snozawa commented Jun 11, 2014

Yes.
Currently, there are few codes and examples to use geometric functions such as body+ in irteus codes rather than rbrain codes.
I'll try it.

@k-okada
Copy link
Member

k-okada commented Jun 23, 2014

i tried to revert this commit and add test code proposed in in #21 (comment), but travis failed (https://travis-ci.org/euslisp/jskeus/builds/28200670), @snozawa, are you sure that the test code (#21 (comment)) works if we remove this commit?

@snozawa
Copy link
Contributor

snozawa commented Jun 24, 2014

Before euslisp/jskeus#100, we needed to arrive at agreement about current situation.

I wrote problem about this in the different place, sorry,
#27
I mentioned about this in Japanese, with a table.

To summarize it,

@snozawa
Copy link
Contributor

snozawa commented Jun 24, 2014

We can run test code on irteusgl by this diff:

diff --git a/irteus/irtgeo.l b/irteus/irtgeo.l
index af39a55..d536d58 100644
--- a/irteus/irtgeo.l
+++ b/irteus/irtgeo.l
@@ -697,6 +697,23 @@
      ))))
     (list a0 a1 a2)))

+(defun face-normal-vector (vertices)
+  (let* ((v1 (first vertices)) (v2) (vlist (rest vertices))
+         (v (float-vector 0 0 0))
+         (normal (float-vector 0 0 0)))
+    (while vlist
+      (setq v2 (pop vlist))
+      (v+ (v* v1 v2 v) normal normal)
+      (setq v1 v2))
+    (setq v2 (car vertices))
+    (v+ (v* v1 v2 v) normal normal)
+    (normalize-vector n0ormal normal)) )
+
+(defmethod polygon
+  (:reset-normal ()
+                 (setq normal (face-normal-vector (rest vertices))
+                       distance (- (v. normal (car vertices))))))
+
 (provide :irtgeo "$Id$")

irteusgl overwrites normalize-vector, so if we re-define face-normal-vector, overwritten normalize-vector is used and the test code works.
(I do not know why is it necessary to re-definition of :reset-normal??)

@snozawa
Copy link
Contributor

snozawa commented Jun 24, 2014

To summarize, before above-mentioned face-normal-vector overwrite,

euslisp name before #21 after #21
eusgl or irteusgl Test Fail Test Fail
jskeusgl Test Success Test Fail

after face-normal-vector overwrite

euslisp name before #21 after #21
eusgl Test Fail Test Fail
irteusgl and jskeusgl Test Success Test Fail

Therefore, we can check the test code by overwriting face-normal-vector.

k-okada added a commit to k-okada/jskeus that referenced this pull request Jun 24, 2014
k-okada added a commit to k-okada/jskeus that referenced this pull request Jun 24, 2014
k-okada added a commit that referenced this pull request Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants