00001 package commandline.baseMeshGeneration.delaunaypackage;
00002
00003
00004
00005
00006
00007 class Circle {
00008 RealPoint c;
00009 float r;
00010
00011 Circle() { c = new RealPoint(); r = 0.0f; }
00012 Circle(RealPoint c, float r) { this.c = c; this.r = r; }
00013 public RealPoint center() { return c; }
00014 public float radius() { return r; }
00015 public void set(RealPoint c, float r) { this.c = c; this.r = r; }
00016
00017
00018
00019
00020 public boolean inside(RealPoint p) {
00021 if (c.distanceSq(p) < r * r)
00022 return true;
00023 else
00024 return false;
00025 }
00026
00027
00028
00029
00030 public void circumCircle(RealPoint p1, RealPoint p2, RealPoint p3) {
00031 float cp;
00032
00033 cp = Vector.crossProduct(p1, p2, p3);
00034 if (cp != 0.0)
00035 {
00036 float p1Sq, p2Sq, p3Sq;
00037 float num;
00038 float cx, cy;
00039
00040 p1Sq = p1.x() * p1.x() + p1.y() * p1.y();
00041 p2Sq = p2.x() * p2.x() + p2.y() * p2.y();
00042 p3Sq = p3.x() * p3.x() + p3.y() * p3.y();
00043 num = p1Sq*(p2.y() - p3.y()) + p2Sq*(p3.y() - p1.y()) + p3Sq*(p1.y() - p2.y());
00044 cx = num / (2.0f * cp);
00045 num = p1Sq*(p3.x() - p2.x()) + p2Sq*(p1.x() - p3.x()) + p3Sq*(p2.x() - p1.x());
00046 cy = num / (2.0f * cp);
00047
00048 c.set(cx, cy);
00049 }
00050
00051
00052 r = c.distance(p1);
00053 }
00054 }