public Edge(Face face, CircLine circLine, Complex start, Complex end) { this.face = face; this.circLine = circLine; this.start = start; this.end = end; }
public FundamentalRegion(int p, int q) { this.p = p; this.q = q; double sinP2 = Math.Pow(Math.Sin(Math.PI / p), 2); double cosQ2 = Math.Pow(Math.Cos(Math.PI / q), 2); r = Math.Sqrt(sinP2 / (cosQ2 - sinP2)); d = Math.Sqrt(cosQ2 / (cosQ2 - sinP2)); phi = Math.PI * (0.5 - ((double) 1 / p + (double) 1 / q)); l1 = Line.Create(Complex.Zero, Complex.One); l2 = Line.Create(Complex.Zero, Math.PI / p); c = Circle.Create(Complex.One * d, r); }
public abstract bool IsNormalTo(CircLine circLine);
public abstract List<Intersection> Intersect(CircLine other);
public bool Equals(CircLine circLine) { if (circLine == null) return false; return Accuracy.LengthEquals(a, circLine.a) && b == circLine.b && Accuracy.LengthEquals(c, circLine.c); }
public override bool IsNormalTo(CircLine circLine) { if (circLine is Line) return circLine.IsNormalTo(this); List<Intersection > intersections = this.Intersect(circLine); if (intersections == null || intersections.Count == 0) return false; Circle other = (Circle)circLine; Complex p = intersections[0].Point; return Accuracy.AngularTolerance > Math.Abs((p - this.Center).ModulusSquared + (p - other.Center).ModulusSquared - (this.Center - other.Center).ModulusSquared); }
public override List<Intersection> Intersect(CircLine other) { List<Intersection > intersections = new List<Intersection>(); if (other is Circle) { Circle otherC = (Circle)other; Complex p0 = this.Center; Complex p1 = otherC.Center; double d = (p1 - p0).Modulus; double r0 = this.Radius; double r1 = otherC.Radius; if (d > (r0 + r1)) // outside return null; if (d < Math.Abs(r0 - r1)) return intersections; if (d == 0) return intersections; double a = (r0 * r0 - r1 * r1 + d * d) / (2 * d); double h = Math.Sqrt(r0 * r0 - a * a); Complex p2 = p0 + a * (p1 - p0) / d; Complex intersect; intersect = new Complex( p2.Re + h * (p1.Im - p0.Im) / d, p2.Im - h * (p1.Re - p0.Re) / d ); intersections.Add(new Intersection( intersect, Math.Atan2(p0.Im - intersect.Im, p0.Re - intersect.Re), Math.Atan2(p1.Im - intersect.Im, p1.Re - intersect.Re) )); intersect = new Complex( p2.Re - h * (p1.Im - p0.Im) / d, p2.Im + h * (p1.Re - p0.Re) / d ); intersections.Add(new Intersection( intersect, Math.Atan2(p0.Im - intersect.Im, p0.Re - intersect.Re), Math.Atan2(p1.Im - intersect.Im, p1.Re - intersect.Re) )); return intersections; } Line line = (Line)other; Complex nearPoint = line.Project(Center).Point - line.Origin; double dist = (Center - nearPoint).Modulus; if (dist - Radius > 0) return null; Complex p; p = Line.Create(nearPoint, line.Angle).Evaluate(Math.Sqrt(RadiusSquared - dist * dist)); intersections.Add(new Intersection( p, line.Angle - Math.Asin(dist / Radius), line.Project(p).Param )); p = Line.Create(nearPoint, line.Angle).Evaluate(-Math.Sqrt(RadiusSquared - dist * dist)); intersections.Add(new Intersection( p, line.Angle + Math.Asin(dist / Radius) + Math.PI, line.Project(p).Param )); return intersections; }
public TrimmedCircLine(Complex start, Complex end) { this.circLine = Line.Create(start, end); this.bounds = circLine.MinorInterval(CircLine.Project(start).Param, CircLine.Project(end).Param); }
public TrimmedCircLine(CircLine circLine, Interval bounds) { this.circLine = circLine; this.bounds = bounds; }
public override bool IsNormalTo(CircLine circLine) { if (circLine is Line) return Math.Abs(Angle - ((Line)circLine).Angle) % (2 * Math.PI) == Math.PI; Complex center = ((Circle)circLine).Center; return this.Project(center).Point == center; }
public override List<Intersection> Intersect(CircLine other) { List<Intersection > intersections = new List<Intersection>(); if (other is Circle) { Circle otherC = (Circle)other; intersections = otherC.Intersect(this); if (intersections == null) intersections = otherC.Intersect(this); return intersections.Select(i => new CircLine.Intersection(i.Point, i.ParamB, i.ParamA)).ToList(); } Line line = (Line)other; Complex denominator = b.Conjugate * line.b - b * line.b.Conjugate; if (denominator == Complex.Zero) return null; Complex z = -(b * line.c - line.b * c) / denominator; intersections.Add(new Intersection(z, Project(z).Param, line.Project(z).Param)); return intersections; }