public bool ContainsPoint(QVector2D point) { if (IsLeaf) { return(data.ContainsKey(point)); } if (children[0].ContainsPoint(point)) { return(true); } if (children[1].ContainsPoint(point)) { return(true); } if (children[2].ContainsPoint(point)) { return(true); } if (children[3].ContainsPoint(point)) { return(true); } return(false); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public bool ContainsPoint(QVector2D point) { if (IsLeaf) { return(data.ContainsKey(point)); } if (children[0].ContainsPoint(point)) { return(true); } if (children[1].ContainsPoint(point)) { return(true); } if (children[2].ContainsPoint(point)) { return(true); } if (children[3].ContainsPoint(point)) { return(true); } return(false); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] private QRegion CalculateChildRegion(QQuadrant quadrant) { QVector2D childHalfRegion = CalculateChildHalfSize(quadrant); return(new QRegion( CalculateChildCenter(quadrant, childHalfRegion), childHalfRegion )); }
private QRegion CalculateChildRegion(QQuadrant quadrant) { QVector2D childHalfRegion = .5f * region.halfRegionSize; return(new QRegion( CalculateChildCenter(quadrant, childHalfRegion), childHalfRegion )); }
private QVector2D CalculateChildCenter(QQuadrant quadrant, QVector2D childHalfRegion) { float xSign = (quadrant.XComponentIsPositive()) ? 1 : -1; float ySign = (quadrant.YComponentIsPositive()) ? 1 : -1; return(new QVector2D( region.center.x + xSign * childHalfRegion.x, region.center.y + ySign * childHalfRegion.y )); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] private QVector2D CalculateChildHalfSize(QQuadrant quadrant) { QVector2D quadrantsCorner = GetQuadrantsCorner(quadrant); float xComponent = .5f * (Math.Max(lastPointInserted.x, quadrantsCorner.x) - Math.Min(lastPointInserted.x, quadrantsCorner.x)); float yComponent = .5f * (Math.Max(lastPointInserted.y, quadrantsCorner.y) - Math.Min(lastPointInserted.y, quadrantsCorner.y)); return(new QVector2D(xComponent, yComponent)); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (!GetType().Equals(obj.GetType())) { return(false); } QVector2D argPoint = (QVector2D)obj; return(x.Equals(argPoint.x) && y.Equals(argPoint.y)); }
public bool InsertPoint(QVector2D point, T pointData) { if (IsLeaf) { if (!region.ContainsPoint(point) || data.ContainsKey(point)) { return(false); } data.Add(point, pointData); if (data.Count == bucketSize && depth != maximumDepth) { Subdivide(); } return(true); } return(InsertInChild(point, pointData)); }
public bool InsertPoint(QVector2D point, T pointData) { if (IsLeaf) { if (!region.ContainsPoint(point) || data.ContainsKey(point)) { return(false); } data.Add(point, pointData); lastPointInserted = point; if (depth != maximumDepth && !subdividing) { Subdivide(); } return(true); } return(InsertInChild(point, pointData)); }
private bool InsertInChild(QVector2D point, T pointData) { if (children[0].region.ContainsPoint(point)) { return(children[0].InsertPoint(point, pointData)); } if (children[1].region.ContainsPoint(point)) { return(children[1].InsertPoint(point, pointData)); } if (children[2].region.ContainsPoint(point)) { return(children[2].InsertPoint(point, pointData)); } if (children[3].region.ContainsPoint(point)) { return(children[3].InsertPoint(point, pointData)); } return(false); }
public bool InsertPoint(QVector2D point, T pointData) { if (IsLeaf) { if (!region.ContainsPoint(point) || points.Contains(point)) { return(false); } if (!data.Equals(pointData) && depth != maximumDepth) { subdivisionPoint = point; subdivisionPointData = pointData; Subdivide(); } else { points.Add(point); } return(true); } return(InsertInChild(point, pointData)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] private QVector2D CalculateChildCenter(QQuadrant quadrant, QVector2D childHalfRegion) { float xSign = (quadrant.XComponentIsPositive()) ? 1 : -1; float ySign = (quadrant.YComponentIsPositive()) ? 1 : -1; return(new QVector2D( lastPointInserted.x + xSign * childHalfRegion.x, lastPointInserted.y + ySign * childHalfRegion.y )); }