MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / point_at

Method point_at

numericals.py:247–264  ·  view source on GitHub ↗

Get a point on line closest to (x, y).

(self, x: float = None, y: float = None)

Source from the content-addressed store, hash-verified

245 return a * x + b * y
246
247 def point_at(self, x: float = None, y: float = None) -> Optional[Point]:
248 """Get a point on line closest to (x, y)."""
249 a, b, c = self.coefficients
250 # ax + by + c = 0
251 if x is None and y is not None:
252 if a != 0:
253 return Point((-c - b * y) / a, y) # pylint: disable=invalid-unary-operand-type
254 else:
255 return None
256 elif x is not None and y is None:
257 if b != 0:
258 return Point(x, (-c - a * x) / b) # pylint: disable=invalid-unary-operand-type
259 else:
260 return None
261 elif x is not None and y is not None:
262 if a * x + b * y + c == 0.0:
263 return Point(x, y)
264 return None
265
266 def diff_side(self, p1: Point, p2: Point) -> Optional[bool]:
267 d1 = self(p1.x, p1.y)

Callers

nothing calls this directly

Calls 1

PointClass · 0.70

Tested by

no test coverage detected