public bool inside(RealPoint p) { if (center.distanceSq(p) < (radius * radius)) return true; else return false; }
public float distanceSq(RealPoint p) { float dx, dy; dx = p.x - x; dy = p.y - y; return (float)(dx * dx + dy * dy); }
public static float dotProduct(RealPoint p1, RealPoint p2, RealPoint p3) { float u1, v1, u2, v2; u1 = p2.X - p1.X; v1 = p2.Y - p1.Y; u2 = p3.X - p1.X; v2 = p3.Y - p1.Y; return u1 * u2 + v1 * v2; }
public Triangulation(int nPoints) { this.nPoints = nPoints; this.points = new RealPoint[nPoints]; for (int i = 0; i < nPoints; i++) { points[i] = new RealPoint(); } maxEdges = 3 * nPoints - 6; //max number of edges edges = new Edge[maxEdges]; for (int i = 0; i < maxEdges; i++) { edges[i] = new Edge(); } nEdges = 0; }
public void circumCircle(RealPoint p1, RealPoint p2, RealPoint p3) { float centerPoint; centerPoint = Vector.crossProduct(p1, p2, p3); if (centerPoint != 0.0) { float p1Sq, p2Sq, p3Sq; float num, den; float cx, cy; p1Sq = p1.X * p1.X + p1.Y * p1.Y; p2Sq = p2.X * p2.X + p2.Y * p2.Y; p3Sq = p3.X * p3.X + p3.Y * p3.Y; num = p1Sq * (p2.Y - p3.Y) + p2Sq * (p3.Y - p1.Y) + p3Sq * (p1.Y - p2.Y); cx = num / (2.0f * centerPoint); num = p1Sq * (p3.X - p2.X) + p2Sq * (p1.X - p3.X) + p3Sq * (p2.X - p1.X); cy = num / (2.0f * centerPoint); center = new RealPoint(cx, cy); } radius = center.distance(p1); }
public float distance(RealPoint p) { return (float)Math.Sqrt(distanceSq(p)); }
public RealPoint(RealPoint p) { x = p.x; y = p.y; }
public void setRealPoints(RealPoint p1, RealPoint p2) { u = p2.X - p1.X; v = p2.Y - p1.Y; }
public Vector(RealPoint p1, RealPoint p2) { u = p2.X - p1.X; v = p2.Y - p1.Y; }
public void SetCircle(RealPoint center, float radius) { this.center = center; this.radius = radius; }