-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLookupGridCell.py
More file actions
30 lines (24 loc) · 1.03 KB
/
LookupGridCell.py
File metadata and controls
30 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import math
from typing import List
from Vector import Vector
class LookupGridCell:
"""
a cell is a bucket of points (of already generated streamlines) which are inside this cell
Each cell contains a list of pointers to the sample points located with the cell.
"""
def __init__(self):
self.samplePoints: List[Vector] = [] # list of sample points located within the cell
def addSamplePoint(self, point: Vector):
# former "occupy()"
self.samplePoints.append(point)
def checkDistance(self, pt: Vector, minDistance: float) -> bool:
"""
returns True if all points inside this cell have distance to passed pt >= minDistance, False otherwise
"""
for sample in self.samplePoints:
# print(f"-sample.distanceTo(pt): {sample.distanceTo(pt)}")
if sample.distanceTo(pt) < minDistance:
# print(f"######FALSE {pt}", sample.distanceTo(pt))
return False
# print(f"######TRUE {pt}, {minDistance})")
return True