//点p1 ,p2 ,p3 から三角形が作れるかを判定(3点が一直線上にないか判定) public static bool isTriangle(LDPoint p1, LDPoint p2, LDPoint p3) { if ((p1.x() * p2.y() + p2.x() * p3.y() + p3.x() * p1.y()) - (p1.x() * p3.y() + p2.x() * p1.y() + p3.x() * p2.y()) != 0) { return(true); } return(false); }
//2点が一定差以内(d以下)にあるかどうか。 public static bool isNearSimple(LDPoint a, LDPoint b, float d) { if (Math.Abs(a.x() - b.x()) > d) return false; if (Math.Abs(a.y() - b.y()) > d) return false; return true; }
//三角形の高さ (底辺p12からp3までの高さ) public static float getTriangleHeight(LDPoint p1, LDPoint p2, LDPoint p3) { LDPoint ab = p2 - p1; LDPoint ac = p3 - p1; float D = Math.Abs(ab.x() * ac.y() - ab.y() * ac.x()); float L = PointUtil.distance(p1, p2); float H = D / L; return(H); }
//2点が一定差以内(d以下)にあるかどうか。 public static bool isNearSimple(LDPoint a, LDPoint b, float d) { if (Math.Abs(a.x() - b.x()) > d) { return(false); } if (Math.Abs(a.y() - b.y()) > d) { return(false); } return(true); }
private static uint qHash(LDPoint key) { return((uint)key.x().GetHashCode());//適当。xだけでハッシュ }
private static uint qHash(LDPoint key) { return (uint)key.x().GetHashCode();//適当。xだけでハッシュ }
//点p1 ,p2 ,p3 から三角形が作れるかを判定(3点が一直線上にないか判定) public static bool isTriangle(LDPoint p1, LDPoint p2, LDPoint p3) { if ((p1.x() * p2.y() + p2.x() * p3.y() + p3.x() * p1.y()) - (p1.x() * p3.y() + p2.x() * p1.y() + p3.x() * p2.y()) != 0) return true; return false; }
//文字列にする public static String toString(LDPoint p) { return("Point (" + p.x() + "," + p.y() + ")"); }
//文字列にする public static String toString(LDPoint p) { return "Point (" + p.x() + "," + p.y() + ")"; }