chavlji Posted October 7, 2009 Posted October 7, 2009 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? Quote
David Bethel Posted October 7, 2009 Posted October 7, 2009 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 Quote
CALCAD Posted October 7, 2009 Posted October 7, 2009 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. Quote
David Bethel Posted October 7, 2009 Posted October 7, 2009 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 Quote
alanjt Posted October 7, 2009 Posted October 7, 2009 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. Quote
lpseifert Posted October 7, 2009 Posted October 7, 2009 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) Quote
Recommended Posts
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.