Need Start/End angles (orientation in space) from 3 coordinates

Discussion in 'AutoCAD' started by Darren J. Young, Apr 27, 2004.

  1. Darren, did you see my final version yesterday? Luis replied shortly after I
    Yes I did. Thanx!

    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, Apr 29, 2004
    #41
  2. Darren J. Young

    BillZ Guest

    I know zip about splines.
    When it comes to plines the bulge factor will tell you what direction the arc travels.
    If you already have 3 points that define the arc, you use the sagitta method that I used in both of my programs.

    rad = (/ (+ (expt d 2)(expt h 2))(* h 2.0))
    cen = (polar p2 (+/- (angle p1 p3)(* pi 0.5)) rad)

    HTH

    Bill
     
    BillZ, Apr 29, 2004
    #42
  3. I know zip about splines.
    True, however I'm not actually pulling and polyline "segment" specific
    geometry. I'm using the vlax-curve functions to extract points along the
    polyline (or spline) at pre configured distances. The area where I could
    be laying a new arc down just might span partially across a straight
    segment and a curved segment. In the case of one file in particular it's
    going to be used on, there are no arcs in the polyline, it's all zigzag
    line segments (I'm assuming it was scanned and vectorized). My program
    will come back through and redraw with a singe arc what's not several
    hundred zigzag line segments that "happen" to make an arc shape.
    Ok, looking back at your first program, I see where you are going.
    That's would have worked, (although I'm to far into the code now to
    switch to your method) I'd have only needed to make one modification and
    that would have been to flag if the start/end points needed swapping or
    not and return it along with the start/end angles in a list to the
    calling function.

    If I have time, perhaps I'll integrate it. Although I still would Jeff's
    code because it was more componentized which allows me to use it as
    library functions to pull other types of data and mix and match it with
    some of my own functions.


    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, Apr 29, 2004
    #43
  4. Darren J. Young

    BillZ Guest

    Good Luck! :)

    Bill
     
    BillZ, Apr 30, 2004
    #44
  5. Jeff (and others)

    You need a slight modification to your RAD3PTS function to check if the
    points are colinear (180deg arc) in which case, your function would
    produce a divide by zero error.

    (defun rad3pts (p1 p2 p3 / A B C R q)
    (setq A (distance p1 p2)
    B (distance p2 p3)
    C (distance p1 p3)
    )
    (if (= (+ A B) C)
    A
    (progn
    (setq q (/ (- (+ (expt A 2) (expt B 2)) (expt C 2)) (* 2 A B)))
    (/ C (* 2 (sqrt (- 1 (expt q 2)))))
    )
    )
    )

    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, May 1, 2004
    #45
  6. Correction to me correction. Note to self...returning the center point
    not the radius. ;^)


    (defun rad3pts (p1 p2 p3 / A B C R q)
    (setq A (distance p1 p2)
    B (distance p2 p3)
    C (distance p1 p3)
    )
    (if (= (+ A B) C)
    p2
    (progn
    (setq q (/ (- (+ (expt A 2) (expt B 2)) (expt C 2)) (* 2 A B)))
    (/ C (* 2 (sqrt (- 1 (expt q 2)))))
    )
    )
    )


    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, May 1, 2004
    #46
  7. Corrected correction to my correction. Just can't think straight. If
    it's wrong the heck with it. You get the idea.

    (defun rad3pts (p1 p2 p3 / A B C R q)
    (setq A (distance p1 p2)
    B (distance p2 p3)
    C (distance p1 p3)
    )
    (if (= (+ A B) C)
    (mapcar '/ (mapcar '+ p1 p3) '(2 2 2))
    (progn
    (setq q (/ (- (+ (expt A 2) (expt B 2)) (expt C 2)) (* 2 A B)))
    (/ C (* 2 (sqrt (- 1 (expt q 2)))))
    )
    )
    )


    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, May 1, 2004
    #47
  8. AHHHHHHHHHHHHHHH! Undo the corrected correction and the correction, wr'e
    back to the original update. Yes we are returning a radius....I was
    looking at the function that called this (which returned the center).
    VERY long week.

    (defun rad3pts (p1 p2 p3 / A B C R q)
    (setq A (distance p1 p2)
    B (distance p2 p3)
    C (distance p1 p3)
    )
    (if (= (+ A B) C)
    p2
    (progn
    (setq q (/ (- (+ (expt A 2) (expt B 2)) (expt C 2)) (* 2 A B)))
    (/ C (* 2 (sqrt (- 1 (expt q 2)))))
    )
    )
    )

    --
    Darren J. Young
    CAD/CAM Systems Developer

    Cold Spring Granite Company
    202 South Third Avenue
    Cold Spring, Minnesota 56320

    Email:
    Phone: (320) 685-5045
    Fax: (320) 685-5052
     
    Darren J. Young, May 1, 2004
    #48
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.