formula for determining angle...

Discussion in 'AutoCAD' started by Devin, Jul 28, 2003.

  1. Devin

    Devin Guest

    I'm in need of the formula for determining the angle of two 2d points
    without using the angle command. It seems to return an error when the value
    is too large.

    Thanks,

    Devin
     
    Devin, Jul 28, 2003
    #1
  2. Devin

    Jim Claypool Guest

    (angtos (angle pt1 pt2) 0 2) returns the angle between points pt1 and pt2
    with a 2 place decimal accuracy
     
    Jim Claypool, Jul 28, 2003
    #2
  3. Devin

    Devin Guest

    I can't use the angle function itself cause it doesn't calc angles when the
    point values are too large.

    Devin
     
    Devin, Jul 28, 2003
    #3
  4. Devin

    David Bethel Guest

    You can always decrase the point values and the angle should not change.

    (angle (cal "p1 * 0.01") (cal "p2 * 0.01"))

    0.01 or 1e-11 or as needed.

    Otherwise calculate the trig functions to find the sin or cos.

    (mapcar '- p2 p1) would give you he rise/run ( x/y ) deltas.


    -David
     
    David Bethel, Jul 28, 2003
    #4
  5. Devin

    OLD-CADaver Guest

    >I can't use the angle function itself cause it doesn't calc angles when the point values are too large.<<

    Works just fine for me.
     
    OLD-CADaver, Jul 29, 2003
    #5
  6. Devin

    Doug Broad Guest

    Devin,
    How large are the point values you are having problems with? Consider:

    Command: (setq pt1 (getpoint))
    (8.48624e+012 4.79534e+012 0.0)

    Command: (setq pt2 (polar pt1 0.70 1000))
    (8.48624e+012 4.79534e+012 0.0)

    Command: (angle pt1 pt2)
    0.7

    Now I imagine that it would work all the way up to numbers in the
    1e15 area before becoming buggy.

    Remember that the output from the angle is in radians.
     
    Doug Broad, Jul 29, 2003
    #6
  7. Devin

    Devin Guest

    The point values are larger than that even. +200 or so. It's in a formula
    that I'm making.

    Thanks for your guys help,

    Devin
     
    Devin, Jul 29, 2003
    #7
  8. Devin

    Jim Claypool Guest

    It appears that AutoCAD can't handle anything past +99
     
    Jim Claypool, Jul 29, 2003
    #8
  9. Devin

    Doug Broad Guest

    Devin
    I assume that you saw the exponents in my points.
    I did some experimenting and it's impossible to set the limits
    higher than 1e99, 1e99 though Autocad can deal with
    numbers up to 1e300.

    Command: (angle '(1e98 1e98 0) '(1e99 1e99 0))
    0.785398

    That angle seems right to me. I can't even imagine the distance
    represented from 0,0 to 1e99,1e99 though.

    Though angles on points more distant from 0,0 can be
    calculated theoretically, Autocad couldn't draw to
    those points.

    David's idea of making the numbers smaller seems the
    only choice that would work. Since the largest number
    that can be stored is around 1e308 (Seeming to be the
    limit of the CPU) something like the following might
    work

    (defun farangle(p1 p2 / reduce myexpt)
    (defun reduce (lst)
    (list
    (/ (car lst) 1e+250)
    (/ (cadr lst) 1e+250)
    0.0))
    (angle (reduce p1)(reduce p2)))

    Of course, you would have to check first to see
    if using that function is appropriate by checking to
    see if the absolute value of any of the number in the
    points exceed 1e99.
     
    Doug Broad, Jul 29, 2003
    #9
  10. If you want the math behind the function here you go:

    Point1 = x1,y1
    Point2 = x2,y2

    ang = iTan((y2-y1)/x2-x1))
    You will get either positive or negative number.
    Angle is from the North or South line depending on bearing direction.

    If x2 is larger and x1 you are moving East. If Y2 is larger than Y1 you are
    moving North. Bearing of line id NE. If X2 is smaller than X1 you are
    moving West. then Bearing direction would be NW. and So on. If you want
    the Azimuth you just add or subtract the angle from the appropriate Quadrant
    (0,90,180,270,360). Bearing direction will tell you which quadrant you are
    in.
     
    William Salling, Jul 29, 2003
    #10
  11. Devin

    Devin Guest

    Thanks Will.
     
    Devin, Jul 29, 2003
    #11
  12. Devin

    Devin Guest

    It's actually an isometric drawing angle conversion based on a supplied xy-ang, x-axis-ang, y-axis-ang, z-axis-ang.  It returns the isometric angle.  And I've finished it.



     



    Thanks for your help guys!



     



    Devin



    "OLD-CADaver" <> wrote in message news:...

    +200 ???????

    What in the heck are you drawing??????

    The diameter of Pluto's orbit in millimeters is something like 1.2e+16.
     
    Devin, Jul 29, 2003
    #12
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.