public static double COS(Dt p1, Dt p2, Dt p3) { double tmp1 = (p1.getX() - p3.getX()) * (p2.getX() - p3.getX()) + (p1.getY() - p3.getY()) * (p2.getY() - p3.getY()); double tmp2 = Math.Sqrt((p3.getX() - p1.getX()) * (p3.getX() - p1.getX()) + (p3.getY() - p1.getY()) * (p3.getY() - p1.getY())); double tmp3 = Math.Sqrt((p2.getX() - p3.getX()) * (p2.getX() - p3.getX()) + (p2.getY() - p3.getY()) * (p2.getY() - p3.getY())); return(tmp1 / tmp2 / tmp3); }
public static bool zhengfuqu(Arc a, List <Dt> data, Dt p3) { if (data[a.startPoint].getX() == data[a.endPoint].getX()) { if (p3.getX() > data[a.startPoint].getX()) { return(!a.po); } else { return(a.po); } } else { double tmp = (data[a.startPoint].getY() - data[a.endPoint].getY()) / (data[a.startPoint].getX() - data[a.endPoint].getX()) * (p3.getX() - data[a.endPoint].getX()) + data[a.endPoint].getY(); return((tmp - p3.getY()) > 0 ? (!a.po) : a.po); } }