Author Topic: (Challenge) calculate arc length  (Read 7278 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: (Challenge) calculate arc length
« Reply #15 on: May 15, 2007, 01:27:09 PM »
... but I guess is that the tangent formula is wrong no?
Luis I got the same answer with your equation.

You arc have total angle (/ Pi 2.)
Okay now I'm totally lost.  This worked, but I don't know how you came up with answer from the pic you posted in the first post.  I can see that the angle difference between the start and end is 90 degrees (which = (/ Pi 2.0)), but I don't see how you get it from your pic.

Guess I need to do a little more studying.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) calculate arc length
« Reply #16 on: May 15, 2007, 01:34:31 PM »
his worked, but I don't know how you came up with answer from the pic you posted in the first post.  I can see that the angle difference between the start and end is 90 degrees (which = (/ Pi 2.0)), but I don't see how you get it from your pic.


I have been assured, that you were mistaken specifying points p1 and p2...
In my picture, I wished to show you, you specify what angle!
http: // www.theswamp.org/index.php? topic=16529.msg200764*msg200764

If you will use an angle pt3-pt1-pt2 it should not be divided on 4.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) calculate arc length
« Reply #17 on: May 15, 2007, 01:42:37 PM »
Tim, it is an example of use, for polylines...  :-)

Code: [Select]
(setq e (entsel "\n Specify a polyline, in the necessary arc segment...")
      b (cdr
         (nth
          (fix
           (vlax-curve-getParamAtPoint (car e) (vlax-curve-getClosestPointTo (car e) (cadr e)))
          ) ;_  fix
          (vl-remove-if-not (function (lambda (x) (= (car x) 42))) (entget (car e)))
         ) ;_  nth
        ) ;_  cdr
      d (fix
         (vlax-curve-getParamAtPoint (car e) (vlax-curve-getClosestPointTo (car e) (cadr e)))
        ) ;_  fix
      d (distance (vlax-curve-getPointAtParam (car e) d)
                  (vlax-curve-getPointAtParam (car e) (1+ d))
        ) ;_  distance
) ;_  setq
(test b d)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: (Challenge) calculate arc length
« Reply #18 on: May 15, 2007, 01:59:36 PM »
Thanks for the clarification Evgeniy.  I don't really understand it, but that is because my trig skills are not up to par.  I will have to teach myself somemore stuff when I get a chance to.  :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: (Challenge) calculate arc length
« Reply #19 on: May 15, 2007, 02:41:21 PM »
Haber que les parece esta funcion :)

Code: [Select]
(defun arcLength  (bulge chord)
  (setq h (* chord (/ bulge 2.0))
r (/ (+ (expt (/ chord 2.0) 2) (expt h 2.0)) (* 2 h)))
  (* r 4.0 (atan bulge)))

test:
Quote
(ARCLENGTH 0.5 100.)
(ARCLENGTH -1.5 100.)
(ARCLENGTH 30. 100.)
(ARCLENGTH -0.1 100.)


115.912
212.939
4617.55
100.665

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: (Challenge) calculate arc length
« Reply #20 on: May 15, 2007, 03:06:15 PM »
Hi,

Here's a trig way

Code: [Select]
(defun test (b d)
  ((lambda (a)
     (* (/ d (sin a)) a)
   )
    (* 2 (atan b))
  )
)

It seems to run faster with a setq

Code: [Select]
(defun test (b d / a)
  (setq a (* 2 (atan b)))
  (* (/ d (sin a)) a)
)
« Last Edit: May 15, 2007, 03:49:36 PM by gile »
Speaking English as a French Frog

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) calculate arc length
« Reply #21 on: May 15, 2007, 03:58:31 PM »
Hi,

Here's a trig way


Hi gile
Very good way!  :-)


Here's my way...
Code: [Select]
(defun lw_arc_Len (b d)
                 ;|
by ElpanovEvgeniy
Find length of an arc
Before start, it is obligatory to check up not a zero tangent!
   b = a tangent of a quarter of a central angle of an arc
   d = it is long chords of a segment
   |;
 (* (atan b) d (+ b (/1. b)))
); _ defun