Home > Community > Forums > PCB SKILL > arc length or angle skill function

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 arc length or angle skill function 

Last post Thu, Nov 15 2012 7:54 AM by Ejlersen. 3 replies.
Started by Ejlersen 14 Nov 2012 09:16 AM. Topic has 3 replies and 987 views
Page 1 of 1 (4 items)
Sort Posts:
  • Wed, Nov 14 2012 9:16 AM

    • Ejlersen
    • Top 10 Contributor
    • Joined on Mon, Jul 28 2008
    • Aalborg, Copenhagen
    • Posts 569
    • Points 9,965
    arc length or angle skill function Reply

    Hi

    Does anyone know of a function to calculate the angle of an arc given 2 coordinates and the radius

    or calculate the arc length

    Either one would work out, but I've not been able to find such a function.

    I know about axlDBGetLength but the problem is that my arc does not have it's own dbid since I'm traversing segments of shapes.

    Thanks in advance 

    Best regards

    Ole

    Best regards Ole
    • Post Points: 20
  • Wed, Nov 14 2012 10:57 AM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 736
    • Points 15,930
    Re: arc length or angle skill function Reply

    Hi Ole,

    Try using these functions:

     defun( DE_angleBetweenPtsWithRadius (pt2, pt1, r, cw), DE_radius2Angle(car(pt2) - car(pt1), cadr(pt2) - cadr(pt1), r) * if(cw, 1, -1))

    defun( DE_circularArcLength (pt1, pt2, r), abs(0.017453 * r * DE_angleBetweenPtsWithRadius(pt1, pt2, r, nil)))

    defun( DE_radius2Angle (x, y, r)

    if(zerop(x) && zerop(y) then 0.0 else DE_Rad2deg(2 * asin(DE_Rndp(if(zerop(x), y / (2 * r * sin(atan2(y, x))), x / (2 * r * sin(atan2(x, y)))), 8))))

    )

    defun( DE_Rad2deg (radians) radians * 90.0 / asin(1))

    defun( DE_Rndp (x, dec), "nx"), round(x * expt(10, dec)) / float(expt(10, dec)))

    Note that, if you are using 16.6 you can use the new function  axlRadToDeg.

    Hopefully the parameters are self explanatory. 

    Dave Elder, Tait Communications
    • Post Points: 35
  • Wed, Nov 14 2012 11:05 AM

    • Ejlersen
    • Top 10 Contributor
    • Joined on Mon, Jul 28 2008
    • Aalborg, Copenhagen
    • Posts 569
    • Points 9,965
    Re: arc length or angle skill function Reply

    Hi Dave

    That was a fast answer, thanks a lot for this.

    I'll try them when I get back to work tomorrow morning :)

    I'm using 16.6 and have to applause for the amount of new skill functions that I've wished for.

    Brand new Excel integration, axlSetVariableFile, axlFormSetMouseActive and much more - can't wait to get started using them.

    Especially the axlFormSetMouseActive where you can get the field the mouse is placed above in a form and then write help about that field to an info field.

    Thanks for the tip on axlRadToDeg - I did not pay attention to that one :-) 

    Have a great day

    Ole

    Best regards Ole
    • Post Points: 5
  • Thu, Nov 15 2012 7:54 AM

    • Ejlersen
    • Top 10 Contributor
    • Joined on Mon, Jul 28 2008
    • Aalborg, Copenhagen
    • Posts 569
    • Points 9,965
    Re: arc length or angle skill function Reply

    Hi Dave

    This seems to work well so far, but just a minor note, theres a ) to much after "nx" :-) 

    defun( DE_Rndp (x, dec), "nx"), round(x * expt(10, dec)) / float(expt(10, dec)))

    Best regards

    Ole

    Best regards Ole
    • Post Points: 5
Page 1 of 1 (4 items)
Sort Posts:
Started by Ejlersen at 14 Nov 2012 09:16 AM. Topic has 3 replies.