Jump to content

Current ucs numeric angle (rads or degs)


MartinSomerville

Recommended Posts

Hello

 

How can I extract the numeric value for the current ucs angle. ie world xy plane angle = 0 but if rotated about z say 30 degrees then angle would be 30 (or pi/180*30 for rads)

 

I guess this mighh get complex with non vert z ucs.

 

Anyway, any help would be grand

 

thanks

martin

Link to comment
Share on other sites

Hi Martin,

 

(or pi/180*30 for rads)
I'm sure it's only a typo, but I thought I'd point out that a conversion from degrees to radians is:

 

(x/180)*pi

 

and going radians to degrees:

 

(x/pi)*180

 

Just in case you get any erroneous results in the future. :P

Link to comment
Share on other sites

You could try this, it should work when the UCS is rotated around Z;

probably a better way to do it using UCSXDIR, UCSYDIR as suggested by ASMI, but I guess I was bored...

(defun c:test (/ p1w p2w ang)
 (defun rtd (a) (/ (* a 180.0) pi))
 (setq p1w (trans '(0 0 0) 1 0)
   p2w (trans '(10 0 0) 1 0)
   ang (rtd (angle p1w p2w))
   )
 (prompt (strcat "\nThe UCS is rotated " (rtos ang 2 4) " degrees from the WCS"))
 (princ)
 )

Link to comment
Share on other sites

thankyou both for your reply.

 

any help is welcome.

 

Now I should be able to nut out, using this info, how to set a text to zero or 90 angle (relative to ucs) with a click (using (50 . x) ). :)

 

 

 

cheers

martin

Link to comment
Share on other sites

I'm sure it's only a typo, but I thought I'd point out that a conversion from degrees to radians is:

 

(x/180)*pi

 

Actually it's just normal order of operations not a typo. Division and multiplication are carried out with the same priority so pi/180*x is exactly the same as the formula you provided. Brackets certainly make things easier to read however. ;)

Link to comment
Share on other sites

Actually it's just normal order of operations not a typo. Division and multiplication are carried out with the same priority so pi/180*x is exactly the same as the formula you provided.

 

I'm afraid that I do not agree... there is no way that you would multiply the input angle by 180 to convert to radians. I understand your point that multiplication/division are treated as the same priority, but this makes no difference if the variables being dealt with are placed incorrectly.

Link to comment
Share on other sites

I'm afraid that I do not agree... there is no way that you would multiply the input angle by 180 to convert to radians. I understand your point that multiplication/division are treated as the same priority, but this makes no difference if the variables being dealt with are placed incorrectly.

 

As written pi/180*x then the value of x is not being multiplied by 180, it's being multiplied by pi/180 which is correct. Normally expressions are written with constants on the left and variables on the right here. Perhaps it's common practice to work expressions from right to left in the UK? In the US evaluation is done from the left to the right so it's possible it's a cultural difference.

Link to comment
Share on other sites

I read the initial post as:

 

pi/(180*x) 

 

and not:

(pi/180)*x 

 

which is probably why I disagreed with your proposal, but I understand now the point you are making.

Link to comment
Share on other sites

which is probably why I disagreed with your proposal, but I understand now the point you are making.

 

And I can certainly see how bracketing clarifies the situation, I tend to use them liberally myself to clarify equations in text forums like this one just to prevent confusion. In a perfect world we'd all be using polish notation. :)

Link to comment
Share on other sites

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