We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › angle with negative value
Page Index Toggle Pages: 1
angle with negative value (Read 463 times)
angle with negative value
Feb 6th, 2007, 6:01am
 
/*I am currently making a program you can draw lines in. If the distance between two points is bigger than 20 pixel, a line is drawn. The angle between the first and the second point is measured, and I want the colour of the line depending on the value of the angle. There´s no problem so far if the value of the angle isn´t a negative number, but as soon as it is, the line doesn´t get the colour I want it to. I suppose there´s something wrong with my writing of negative numbers, can somebody please tell me what it is? I just can´t find out!

Here´s the code area I´m talking about (I´m well aware that it unfortunately is not that nice and clean):*/

if (tDifAngle>0){
       if(tDifAngle<80){
       stroke (255,255,0);
       }
       else {
         if(tDifAngle>79){
           if(tDifAngle<200){
             stroke (255,127,0);
             }
             else {
               if(tDifAngle>199){
                 stroke (255,0,0);
                 }
                 else {
                   if(tDifAngle<0){
                     if(tDifAngle>-80){
                   stroke(0,160,227);
                   }
                   else {
                     if(tDifAngle<-79){
                       if(tDifAngle>-200){
                         stroke (0,49,191);
                         }
                         else {
                           if(tDifAngle<-199){
                             stroke (0);
                             }
                           }
                       }
                     }
                     
                   }
                   }
               }
           }
         }
       }
Page Index Toggle Pages: 1