Jump to content

Recommended Posts

Posted

I made a function that asks user for new horizont and it then turns UCS accordingly. So selected line is taken as reference for new horizontal axe (X).

 

Problem is I calculate angle using ANGLE function. It returns radians. But

(command "ucs" "z" (* -1 Ang) ) accepts only Degree values for Ang. So I have to convert radians to degrees. I use following function:

 

(defun Rad2Deg (a)

(/ (* a 180.0) pi))

 

BUT! Is this conversion 100% correct? I suspect, that value in degrees is beeing slightly rounded. For like 1^-10...

 

Can I be sure, that this is not the issue? Is this Rad2Deg pure 100% correct?

Posted

You will never get a PC to be 100% accurate when dealing with real numbers. ACAD uses 15 significant digits. Always try to use ( equal n n fuzz ) when comparing reals. It will save you a lot of headaches. -David

Posted

chavlji,

Your function is as good as it gets. As David said, Autocad is limited to 15 decimal places. As a practical matter, that's pretty damned accurate. Using your function and its inverse, I experimentally converted a variety of numbers from radians to degrees and back 32 times for each case and there was no loss of accuracy.

Posted

Just a nit pick. 'puters use 16 significant digits or places, ( less 1 for negatives ). It will drop the decimals beyond that. It makes a difference with really large numbers.

 

Command: (setq r1 1234567890123.45678901234)
1.23457e+012

Command: (rtos r1 2 14)
"1234567890123.456"

 

-David

Posted
Just a nit pick. 'puters use 16 significant digits or places, ( less 1 for negatives ). It will drop the decimals beyond that. It makes a difference with really large numbers.

 

Command: (setq r1 1234567890123.45678901234)
1.23457e+012

Command: (rtos r1 2 14)
"1234567890123.456"

-David

Thanks for the less on David. :)

Posted
I made a function that asks user for new horizont and it then turns UCS accordingly. So selected line is taken as reference for new horizontal axe (X).

Did you know that Autocad has a way to do this...

UCS > OBject (or Entity)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...