public class Pvector {
public double L=0,z=0;
public double a=0,x=0;
public double b=0,y=0;
public double GetL(){return L;}
public double GetZ(){return L;}
public void SetL(double l){
this.L=l;
this.z=l;
}
public void SetZ(double z){
this.L=z;
this.z=z;
}
public double GetA(){return a;}
public double GetX(){return a;}
public void SetA(double a){
this.a=a;
this.x=a;
}
public void SetX(double x){
this.a=x;
this.x=x;
}
public double GetB(){return b;}
public double GetY(){return b;}
public void SetB(double b){
this.b=b;
this.y=b;
}
public void SetY(double y){
this.b=y;
this.y=y;
}
}
///二维平面中,据坐标值判断点在三角形内
public boolean isInTrigon(Pvector[] trigABC,Pvector trigS) {
Pvector a = trigABC[0];
Pvector b = trigABC[1];
Pvector c = trigABC[2];
double signOfTrig = (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x);
double signOfAB = (b.x - a.x)*(trigS.y - a.y) - (b.y - a.y)*(trigS.x - a.x);
double signOfCA = (a.x - c.x)*(trigS.y - c.y) - (a.y - c.y)*(trigS.x - c.x);
double signOfBC = (c.x - b.x)*(trigS.y - c.y) - (c.y - b.y)*(trigS.x - c.x);
boolean d1 = (signOfAB * signOfTrig > 0);
boolean d2 = (signOfCA * signOfTrig > 0);
boolean d3 = (signOfBC * signOfTrig > 0);
return d1 && d2 && d3;
}