SHARE
TWEET

my flash triangle

a guest Aug 14th, 2019 153 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function IsIn(v : vector2) : Boolean
  2.         {
  3.             var xaxis1 : vector2 = new vector2(v2.x - v1.x, v2.y - v1.y);
  4.             var yaxis1 : vector2 = new vector2(v3.x - v1.x, v3.y - v1.y);
  5.            
  6.             var a11 = xaxis1.x;
  7.             var a12 = xaxis1.y;
  8.             var a21 = yaxis1.x;
  9.             var a22 = yaxis1.y;
  10.            
  11.             var det : Number = (a11 * a22 - a21 * a12);
  12.             var fa11 : Number = a22 / det;//(a11 * a22 - a21 * a12);
  13.             var fa12 : Number = -a12 / det;// (yaxis1.y * xaxis1.x - xaxis1.y * yaxis1.x);
  14.             var fa21 : Number = -a21 / det;//(yaxis1.y * xaxis1.x - xaxis1.y * yaxis1.x);
  15.             var fa22 : Number = a11 / det;//(yaxis1.y * xaxis1.x - xaxis1.y * yaxis1.x);
  16.            
  17.             var nv:vector2 = new vector2(0, 0);
  18.             nv.x = v.x - v1.x;
  19.             nv.y = v.y - v1.y;
  20.             var vc : vector2 = new vector2(nv.x * fa11 + nv.y * fa21, nv.x * fa12 + nv.y * fa22);
  21.             if (vc.x > 0 && vc.y > 0 && ((vc.x < (1.0-vc.y))) && vc.x <= 1.0 && vc.y <=1.0)
  22.             {
  23.                 trace("in");
  24.                 return true;
  25.             }
  26.             return false;
  27.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top