I am relatively new to OpenSCAD, but I have plenty of experience in software development. I have written the following function:
function GetSlope(angle)=sin(angle)/cos(angle);
When the angle is 90° or 270° the function will, of course, return inf due to cos evaluating to 0, and therefore trying to divide by 0. This is obviously to be expected, but I need to be able to detect this when using the function. OpenSCAD contains several type-testing functions, but I could not find an is_inf function or a constant named inf to do my own test. Is there a way to test for inf, or do I need to manually test the value from outside the function?
You can use
1/0as theinfconstant you are looking for, it's not very clean but it works. You could also check ifcos(angle) == 0although I don't think that's what you want.(also you may already know it but
sin(angle) / cos(angle) = tan(angle))UPDATE :
according to the documentation :