i am working on a feature that actually draw some helical curves and circles. Therefor i frequently have to calulate an angle in the x-y-plane. Ok, thats easy. To get the right actual angle in the range of 0-360 degrees it wrote a function
function quadrantCorrection(FPoint startp, FDouble phi):FDouble if (AND(startp.getY()>=0,startp.getX()<0)) // 2th. Q. phi = 180-phi elseif (AND(startp.getY()>=0,startp.getX()>=0)) // 1st Q. phi = phi elseif (AND(startp.getY()<0,startp.getX()>=0)) // 4nd. Q. echo("Q4, phi " + phi) phi = 360-phi echo("Q4, phiCorr " + phi) elseif (AND(startp.getY()<0,startp.getX()<0)) // 3rd. Q. phi = 180+phi endif return(phi) endfunction
I use this function for a great number of times and it seems to work fine. However in the attached project in the feature definition "MixerBasemesh" at line 340 it fails for whatever reason.
Below some debug output is given, the x and y coordinate show that the point is located in 4th quadrant. The function above detects this correctly (indicated by the debug output "Q4, phi 7.44226") but it does not compensate (phi=360-phi) the angle as shown by "Q4, phiCorr 7.44226".
phiE: 7.44226 x: 19.9307 y: -2.60349 Q4, phi 7.44226 Q4, phiCorr 7.44226 phiECorr: 7.44226 phi: -37.5577 phi: -37.5577 -----
This is a somwhat strange behaviour, i have no idea what i am doing wrong. Any comments on this.
I use V4.1.0 on Ubuntu.
Thank you for your help an best regards,