def generate_plottable_points_between_twopoints(cls, point1: List[Point], point2: List[Point]): vec = Vector.create_vector_from_2points(point1, point2) distance_between_point1_2 = Point.euclidean_distance(point1, point2) max_distance_between2points = 1 min_distance_between2points = max_distance_between2points * .5 unit = vec.UnitVector lst_results = [] delta = distance_between_point1_2 / 10 #some random value last_point = point1 last_t = 0 max_t = distance_between_point1_2 while (True): new_t = last_t + delta if (new_t > max_t): break next_point = Point(point1.X + unit.X * new_t, point1.Y + unit.Y * new_t) distance = Point.euclidean_distance(last_point, next_point) if (distance < max_distance_between2points and distance > min_distance_between2points): #just right last_t = new_t lst_results.append(next_point) last_point = next_point continue elif (distance <= min_distance_between2points): #too close delta = delta * 1.5 continue elif (distance >= max_distance_between2points): #too far delta = delta * .5 continue else: continue return lst_results
def distance(self): if (self._distance != -1): return self._distance vec = Vector.create_vector_from_2points(self.point1, self.point2) self._distance = vec.Length return self._distance
def test_create_vector(self): p1=Point(1,1) p2=Point(2,2) v=Vector.create_vector_from_2points(p1,p2) self.assertEquals(v.X,1) self.assertEquals(v.Y,1)