angle pt1 pt2 decimal places

angle pt1 pt2 decimal places

cadking2k5
Advocate Advocate
1,370 Views
10 Replies
Message 1 of 11

angle pt1 pt2 decimal places

cadking2k5
Advocate
Advocate

(Setq angln (angle pt1 pt2))
How do I get this to give out an angle with 8 decimal places
I have the units set to 8 and it is draw at 90 or 1.5708  and when I type in (= angln (cvunit 90 "DEGREE" "RADIAN")) nil comes up

0 Likes
1,371 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

When comparing real type data it is better to use equal with a fuzz factor (since the decimal parts may be slightly off). Read AutoCAD help here. Try

(equal angln (cvunit 90 “DEGREE” “RADIAN”) 1e-4)

I do not have access to AutoCAD at the moment and so cannot test it, but you get the idea.

0 Likes
Message 3 of 11

cadking2k5
Advocate
Advocate
this worked (equal (angle hr1 hr2) (cvunit 90 "DEGREE" "RADIAN")1e-4)
0 Likes
Message 4 of 11

john.uhden
Mentor
Mentor

What you see is not all that's there.  If you want to see more places after the decimal (or degree symbol) use the angtos function, which will display the angle as a string 

 

Command: dimzin

Enter new value for DIMZIN <8>: 1

Command: (angtos pi 0 8)
"180.00000000"

John F. Uhden

0 Likes
Message 5 of 11

cadking2k5
Advocate
Advocate

but then none of these will not come up T to this all nil

(setq ang (angtos pi 0 8))

(equal ang (cvunit 180 "DEGREE" "RADIAN") )

(equal angs (cvunit 40 "DEGREE" "RADIAN") 1e-8)

(eq angs (cvunit 40 "DEGREE" "RADIAN"))

(= angs (cvunit 40 "DEGREE" "RADIAN"))

 

0 Likes
Message 6 of 11

Ranjit_Singh
Advisor
Advisor

@cadking2k5 wrote:

but then none of these will not come up T to this all nil

(setq ang (angtos pi 0 8))

(equal ang (cvunit 180 "DEGREE" "RADIAN") ) ;comparing string and real types

(equal angs (cvunit 40 "DEGREE" "RADIAN") 1e-8) ;same as above

(eq angs (cvunit 40 "DEGREE" "RADIAN)) ;same as above

(= angs (cvunit 40 "DEGREE" "RADIAN")) ;same as above


@john.uhden was suggesting you can inspect the data to 8 decimal places. For comparison, however, you will need the data types to be in the same format. AutoCAD is accurate up to 15 decimal places and if your difference between the 2 values is less than 1e-15, = will work fine. Else you need to use equal and specify a fuzz factor.

0 Likes
Message 7 of 11

john.uhden
Mentor
Mentor

Ranjit:

 

You should know that I revert to many old-fashioned techniques to solve things.  I am not even hip to cvunit.  Who needs it?  It's just math.  Or will cvunit save me 5 nanoseconds per month if I do the same thing 100,000 times per day?

John F. Uhden

0 Likes
Message 8 of 11

cadking2k5
Advocate
Advocate

how do I make the data types to be in the same format.

0 Likes
Message 9 of 11

john.uhden
Mentor
Mentor

The same format as what?

John F. Uhden

0 Likes
Message 10 of 11

cadking2k5
Advocate
Advocate

what ever you all are talking about to inspect the data to 8 decimal places.

0 Likes
Message 11 of 11

john.uhden
Mentor
Mentor

Command: (angtos (/ pi 7) 0 8)
"25.71428571"

 

Command: (angtos (/ pi 7) 1 8)
"25d42'51.4286\""

 

Command: (angtos (/ pi 7) 2 8)
"28.57142857g"

 

Command: (angtos (/ pi 7) 3 8)
"0.44879895r"

 

Command: (angtos (/ pi 7) 4 8)
"N 64d17'8.5714\" E"

 

But notice that the evaluations are all strings.  That's the only way you can control the display of desired precision with reals.  Well, unless you convert them into integers.

John F. Uhden

0 Likes