update:
This commit is contained in:
@@ -117,12 +117,6 @@ namespace TMI_practicum
|
||||
if (intersects == null) return;
|
||||
foreach (var intersection in intersects)
|
||||
{
|
||||
// if (upper)
|
||||
// {
|
||||
// if (intersection.Y < circle.Y) continue;
|
||||
// }
|
||||
// else if (intersection.Y > circle.Y) continue;
|
||||
|
||||
if (intersections.Contains(intersection)) continue;
|
||||
events.Add(new Event(Event.EventType.Intersection, intersection.X, circle, intersection.Y,
|
||||
new[] {new C5.KeyValuePair<SegmentKey, Circle>(segment, circle), neighbour}));
|
||||
@@ -197,7 +191,7 @@ namespace TMI_practicum
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lastX.Equals(_sweepline)) return _lastY;
|
||||
if (_lastX == _sweepline) return _lastY;
|
||||
_lastX = _sweepline;
|
||||
_lastY = CalculateY(_circle, Type);
|
||||
return _lastY;
|
||||
@@ -218,10 +212,10 @@ namespace TMI_practicum
|
||||
|
||||
public int CompareTo(SegmentKey other)
|
||||
{
|
||||
if (_identifier.Equals(other._identifier)) return Type.CompareTo(other.Type);
|
||||
if (!Y.Equals(other.Y)) return Y.CompareTo(other.Y);
|
||||
if (_identifier == other._identifier) return Type.CompareTo(other.Type);
|
||||
if (Y != other.Y) return Y.CompareTo(other.Y);
|
||||
|
||||
return Type.Equals(other.Type) ? _identifier.CompareTo(other._identifier) : Type.CompareTo(other.Type);
|
||||
return Type == other.Type ? _identifier.CompareTo(other._identifier) : Type.CompareTo(other.Type);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -229,7 +223,7 @@ namespace TMI_practicum
|
||||
if (obj == null || GetType() != obj.GetType()) return false;
|
||||
SegmentKey r = (SegmentKey) obj;
|
||||
|
||||
return _identifier.Equals(r._identifier) && Type.Equals(r.Type);
|
||||
return _identifier == r._identifier && Type == r.Type;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -246,6 +240,7 @@ namespace TMI_practicum
|
||||
|
||||
private static double CalculateY(Circle circle, SegmentKey.SegmentType type)
|
||||
{
|
||||
if (_sweepline > circle.X + circle.R || _sweepline < circle.X - circle.R) return circle.Y;
|
||||
return type == SegmentKey.SegmentType.Upper
|
||||
? Math.Round(Math.Sqrt(circle.R * circle.R - Math.Pow(_sweepline - circle.X, 2)) + circle.Y, 14)
|
||||
: Math.Round(-Math.Sqrt(circle.R * circle.R - Math.Pow(_sweepline - circle.X, 2)) + circle.Y, 14);
|
||||
|
Reference in New Issue
Block a user