formula for determining angle...

Devin

Usenet Archive
Joined
Sep 27, 2001
Messages
342
Reaction score
0
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
 
(angtos (angle pt1 pt2) 0 2) returns the angle between points pt1 and pt2 with a 2 place decimal accuracy
 
I can't use the angle function itself cause it doesn't calc angles when the point values are too large.

Devin
 
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
 
>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.
 
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.
 
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
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.
 
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.
 
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:

+200 ???????

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

The diameter of Pluto's orbit in millimeters is something like 1.2e+16.
 

Latest threads

Back
Top