Jump to content

Photo

Dead Zones in Script


  • Please log in to reply
No replies to this topic

#1 Linkus

Linkus

    .

  • Members
  • Real Name:Adam

Posted 02 March 2008 - 04:54 PM

(Originally posted at AGN: Topic)

CODE
import "std.zh"

ffc script vacuum{
    void run(){
        while(true){
            int x = 128;
            int y = 84;
            int b; int c; int p; int q;
            int suckx = 1;
            int sucky = 1; //suction pawer
            //int r = n; //r is radius in pixels
            this->X = x; this->Y = y;
            p = Link->X - x;
            q = Link->Y - y;
            b = Pow(Tan(q / p), -1); //checks angle between Link and FFC
            //if(r <= (sqrt((p * p) + (q * q)))
            //^distance formula to check if Link is in range.
            //remove "//' at the beginning of lines 7, 11, and  
            //42 and replace "n" with length of radius.    
            
                if((b == 0) && (p > 0)){
                    Link->X -= suckx;
                }
                if((b > -90) || (b <= 90) && (p > 0) && (q > 0)){
                    (Link->X - suckx) & (Link->Y - sucky);
                }
                if((b == 0) && (q > 0)){
                    Link->Y -= sucky;
                }
                if((b >= -90) || (b <= 90) && (p < 0) && (q > 0)){
                    (Link->X + suckx) & (Link->Y - sucky);
                }
                if((b == 0) && (p < 0)){
                    Link->X += suckx;
                }
                if((b > -90) || (b <= 90) && (p < 0) && (q < 0)){
                        (Link->X + suckx) & (Link->Y + sucky);
                }
                if((b == 0) && (q < 0)){
                    Link->Y += sucky;
                }
                if((b >= -90) || (b <= 90) && (p > 0) && (q < 0)){
                        (Link->X - suckx) & (Link->Y + sucky);
                }
            //}
        Waitframes(3); //controls suck rate
        }
    }
}

So, I'm wondering how I could fix the dead zones between 46 to 89 and -46 to -89 degrees. I've thought of an inverse x and y, but that doesn't work...

EDIT:
QUOTE
b = Pow(Tan(q / p), -1);

Found the culprit. It's not the equivalent of arctan. I need to rewrite this to include all angles between 0 and 90, or 0 and -90.
EDIT: Never mind, I fixed the problem by changing all my OR statements into AND statements.

Edited by Linkus, 02 March 2008 - 06:31 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users