Author Topic: Check line for accuracy  (Read 11856 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Check line for accuracy
« Reply #30 on: March 01, 2007, 09:41:54 AM »
OK, I'm having a problem with this angle:
a = 6.25215 or 358.222 deg

_1_$ (sin (+ a a))
-0.0620258
_1_$ (rtod (sin (+ a a)))
-3.55382
_1_$ (- (* 2 pi) a)
0.0310328
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

fools

  • Newt
  • Posts: 72
  • China
Re: Check line for accuracy
« Reply #31 on: March 01, 2007, 10:05:56 AM »
Welcome to the swamp fools

Nice lisp, although there is a miss-placed parentheses in your post

Code: [Select]
  ((lambda (a)
            (equal (sin (+ a a)[color=red])[/color] 0.0 0.0523599) ; +-3 deg
          )
         (vla-get-angle Obj)
  )

Thanks CAB for your greeting. And thanks u again for pointing out my mistake. :-)

In my function , +-3 deg is double.   (sin (/ pi 30))=0.104528 , not 0.0523599.
other angles :
Code: [Select]
(mapcar (function (lambda (x) (sin (/ (* 2 PI x) 180)))) '(3 87 93 177 183 267 273 357))
;;return (0.104528 0.104528 -0.104528 -0.104528 0.104528 0.104528 -0.104528 -0.104528)
So the code is
Code: [Select]
((LAMBDA (a)
   (EQUAL (SIN (+ a a)) 0.0 0.104528) ; +-3 deg
 )(VLA-GET-ANGLE Obj)
)
Good good study , day day up . Sorry about my Chinglish .

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Check line for accuracy
« Reply #32 on: March 01, 2007, 10:10:17 AM »
You'er quite right. Too much math for me. :-)

I did find my mistake though, using my test rig.
Code: [Select]
(defun c:test2()

  (mapcar '(lambda (a / b)
             (setq b (print (rtod a)))
             (print a)
             (print (sin (+ a a)))
             (print (equal (sin (+ a a)) 0.0 0.104528)) ; +-3 deg
             (print)
          )
         (mapcar 'dtor '(2 2.9 3 87 87.9 92 92.9 94 176 176.9 177 182 182.9 183 267 267.9 268 272 272.9 273 357 357.9 359))
  )
  (princ)
  )

PS, yes the "Double" got me. :oops:
« Last Edit: March 01, 2007, 10:11:55 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Check line for accuracy
« Reply #33 on: March 01, 2007, 01:13:49 PM »
how about this solution? :-) a little faster
because SIN(2*A)=2*SIN(A)*COS(A)
Code: [Select]
((LAMBDA (a)
   (EQUAL (sin (+ a a) 0.0 0.104528))
 )
 (vla-get-Angle Obj)
)

Thank you, fools  :-)
Realy nice one, I like it, indeed.
Speaking English as a French Frog