cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Translate the entire conversation x

A problem when dividing two vectors in atan

Cornel
19-Tanzanite

A problem when dividing two vectors in atan

 

Hi,


I am sure that something I do not do correctly, I believe there with that condition of an=0.

Cornel_0-1751545903776.png

 

 

Cornel_2-1751546220142.png
 
Prime 10 file attached.
ACCEPTED SOLUTION

Accepted Solutions
ttokoro
21-Topaz I
(To:Cornel)

image.pngimage.pngimage.png

image.pngimage.png

image.png  So only without = after it, you can get all what you want.

image.png

image.png

View solution in original post

4 REPLIES 4
Cornel
19-Tanzanite
(To:Cornel)

 

 

Hi,

I am not sure why is not seen the text of the first message, but here is:

I am sure that something I do not do correctly, I believe there with that condition of an=0.
How to achieve the result of second vector (the correct one below)?
Prime 10 file attached (in first post)

Cornel_0-1751546560714.png

 

Cornel_2-1751546220142.png

ttokoro
21-Topaz I
(To:Cornel)

image.pngimage.pngimage.png

image.pngimage.png

image.png  So only without = after it, you can get all what you want.

image.png

image.png

Werner_E
25-Diamond I
(To:Cornel)

As @ttokoro  had shown you are running into numerical inaccuracies, presumably because of the numeric integration used.

You can make these inaccuracies/round-offs visible using symbolic evaluation:

Werner_E_0-1751563050807.png

So the values you believe being zero aren't zero and that's the reason "atan" yields a 'valid' result.

BTW, using a:=a= and b:=b= is mandatory as otherwise you won't see the errors of the numeric calculation but rather just the errors the symbolic calculations makes, too. In @ttokoro 's screenshot you only see the errors made by symbolic calculation!

 

So the solution is either

1) using a threshold as seen in @ttokoro 's picture, but I would strongly suggest to use the absolute value function because the round-off can be in any direction -> 

Werner_E_3-1751564044143.png

2) or simply rounding the values to a degree which is acceptable for you.

Werner_E_4-1751564087560.png

 

I also wonder why you would bother with the range variable instead of simply using vectorization and why you don't use the "atan2" function instead of "atan".

"atan2" catches the 'error' when a=0 and return the correct 90°. It still throws an error if both values are zero because in mathematical definition the angle is undefined in that case. So it may be a good idea to define an "Atan2" function which catches this error as well. Of course you could change it to return 0  instead of NaN in case both values are zero if this is more convenient for your application.

Werner_E_2-1751563650285.png

BTW, of course the last but one value must be -90° and not +90° as you screenshot claims!

 

 

 

Werner_E
25-Diamond I
(To:Werner_E)

BTW, why not using a more generic approach like

Werner_E_8-1751566302825.png

 

You get the correct value for the angles either by using symbolic evaluation

Werner_E_6-1751566012945.png

or without using symbolics again by using rounded values

Werner_E_7-1751566074646.png

 

 

 

Announcements


Top Tags