Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
How I can tell matcade when the angle is divided by zero consider the value to be zero
Solved! Go to Solution.
The problem is not that the first argument is zero - atan2 can handle that and returns + or - pi/2.
The problem only occurs if BOTH arguments are zero because then the angle is undefined.
So you have to ask for both arguments being zero.
Furthermore you should not use "return" as this command terminates the program.
You also must ask for the arguments being both zero BEFORE you call atan2 as otherwise the error would be thrown again.
Don't use "deg" when you define "Angle", use it when you display it!
Here is a way to get what you are looking for:
If you want to save space you may also use the if-function instead of the if-statement (at the cost of readability and clearness):
You may also consider to re-define the atan2 function so that it always will return 0 in the case both arguments are zero.
You can do this at the top of the sheet, maybe in a collapsed region along with other utility functions and definitions.
When you re-define atan2 you should label it as being "function" so that it really replaces the built-in function with the same name.
The problem is not that the first argument is zero - atan2 can handle that and returns + or - pi/2.
The problem only occurs if BOTH arguments are zero because then the angle is undefined.
So you have to ask for both arguments being zero.
Furthermore you should not use "return" as this command terminates the program.
You also must ask for the arguments being both zero BEFORE you call atan2 as otherwise the error would be thrown again.
Don't use "deg" when you define "Angle", use it when you display it!
Here is a way to get what you are looking for:
If you want to save space you may also use the if-function instead of the if-statement (at the cost of readability and clearness):
You may also consider to re-define the atan2 function so that it always will return 0 in the case both arguments are zero.
You can do this at the top of the sheet, maybe in a collapsed region along with other utility functions and definitions.
When you re-define atan2 you should label it as being "function" so that it really replaces the built-in function with the same name.
Thank very very much for your help