23 else throw new Exception(
"Tried to add third vertex!");
32 private VNode _Left = null, _Right = null;
62 else if(Right==ChildOld)
64 else throw new Exception(
"Child not found!");
135 throw new Exception(
"No Left Leaf found!");
236 VG.Vertizes.Add(VNew);
252 eu.Edge.AddVertex(VNew);
257 eo.Edge.AddVertex(VNew);
268 if(eo.Parent == null)
308 this.Flipped = Flipped;
312 public double Cut(
double ys,
double x)
321 internal abstract class VEvent : IComparable
323 public abstract double Y {
get;}
324 public abstract double X {
get;}
325 #region IComparable Members 330 throw new ArgumentException(
"obj not VEvent!");
331 int i = Y.CompareTo(((VEvent)obj).Y);
334 return X.CompareTo(((VEvent)obj).X);
347 public override double Y
355 public override double X
369 public override double Y
377 public override double X
385 public bool Valid =
true;
390 public static readonly
Vector VVInfinite =
new Vector(
double.PositiveInfinity,
double.PositiveInfinity);
391 public static readonly
Vector VVUnkown =
new Vector(
double.NaN,
double.NaN);
392 internal static double ParabolicCut(
double x1,
double y1,
double x2,
double y2,
double ys)
409 if(Math.Abs(y1-ys)<1e-10 && Math.Abs(y2-ys)<1e-10)
411 if(Math.Abs(y1-ys)<1e-10)
413 if(Math.Abs(y2-ys)<1e-10)
415 double a1 = 1/(2*(y1-ys));
416 double a2 = 1/(2*(y2-ys));
417 if(Math.Abs(a1-a2)<1e-10)
419 double xs1 = 0.5/(2*a1-2*a2)*(4*a1*x1-4*a2*x2+2*Math.Sqrt(-8*a1*x1*a2*x2-2*a1*y1+2*a1*y2+4*a1*a2*x2*x2+2*a2*y1+4*a2*a1*x1*x1-2*a2*y2));
420 double xs2 = 0.5/(2*a1-2*a2)*(4*a1*x1-4*a2*x2-2*Math.Sqrt(-8*a1*x1*a2*x2-2*a1*y1+2*a1*y2+4*a1*a2*x2*x2+2*a2*y1+4*a2*a1*x1*x1-2*a2*y2));
421 xs1=Math.Round(xs1,10);
422 xs2=Math.Round(xs2,10);
435 if(A==B || B==C || A==C)
436 throw new Exception(
"Need three different points!");
437 double tx = (A[0] + C[0])/2;
438 double ty = (A[1] + C[1])/2;
440 double vx = (B[0] + C[0])/2;
441 double vy = (B[1] + C[1])/2;
452 ux = (C[1] - A[1])/(A[0] - C[0]);
463 wx = (B[1] - C[1])/(B[0] - C[0]);
467 double alpha = (wy*(vx-tx)-wx*(vy - ty))/(ux*wy-wx*uy);
469 return new Vector(tx+alpha*ux,ty+alpha*uy);
474 Hashtable CurrentCircles =
new Hashtable();
476 VNode RootNode = null;
477 foreach(
Vector V
in Datapoints)
491 CurrentCircles.Remove(((VCircleEvent)VE).NodeN);
492 if(!((VCircleEvent)VE).Valid)
496 else throw new Exception(
"Got event of type "+VE.GetType().ToString()+
"!");
499 if(CurrentCircles.ContainsKey(VD))
502 CurrentCircles.Remove(VD);
508 CurrentCircles[VD]=VCE;
513 Vector DP = ((VDataEvent)VE).DataPoint;
static VDataNode LeftDataNode(VDataNode Current)
static VoronoiGraph ComputeVoronoiGraph(IEnumerable Datapoints)
static VDataNode FindDataNode(VNode Root, double ys, double x)
A vector class, implementing all interesting features of vectors
static Vector CircumCircleCenter(Vector A, Vector B, Vector C)
override bool Equals(object obj)
Compares this vector with another one
static int ccw(Point P0, Point P1, Point P2, bool PlusOneOnZeroDegrees)
static VNode ProcessCircleEvent(VCircleEvent e, VNode Root, VoronoiGraph VG, double ys, out VDataNode[] CircleCheckList)
static VDataNode FirstDataNode(VNode Root)
double Cut(double ys, double x)
static VCircleEvent CircleCheckDataNode(VDataNode n, double ys)
static double ParabolicCut(double x1, double y1, double x2, double y2, double ys)
void Replace(VNode ChildOld, VNode ChildNew)
Summary description for Hashset.
static readonly Vector VVUnkown
static double Dist(double x1, double y1, double x2, double y2)
VEdgeNode(VoronoiEdge E, bool Flipped)
static VDataNode RightDataNode(VDataNode Current)
static VEdgeNode EdgeToRightDataNode(VDataNode Current)
int CompareTo(object obj)
static VNode ProcessDataEvent(VDataEvent e, VNode Root, VoronoiGraph VG, double ys, out VDataNode[] CircleCheckList)
Will return the new root (unchanged except in start-up)