MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / Point

Class Point

geometry/jarvis_march.py:25–41  ·  view source on GitHub ↗

Represents a 2D point with x and y coordinates.

Source from the content-addressed store, hash-verified

23
24
25class Point:
26 """Represents a 2D point with x and y coordinates."""
27
28 def __init__(self, x_coordinate: float, y_coordinate: float) -> None:
29 self.x = x_coordinate
30 self.y = y_coordinate
31
32 def __eq__(self, other: object) -> bool:
33 if not isinstance(other, Point):
34 return NotImplemented
35 return self.x == other.x and self.y == other.y
36
37 def __repr__(self) -> str:
38 return f"Point({self.x}, {self.y})"
39
40 def __hash__(self) -> int:
41 return hash((self.x, self.y))
42
43
44def _cross_product(origin: Point, point_a: Point, point_b: Point) -> float:

Callers 15

test_point_creationMethod · 0.90
test_point_equalityMethod · 0.90
test_point_reprMethod · 0.90
test_point_hashMethod · 0.90
test_triangleMethod · 0.90
test_collinear_pointsMethod · 0.90
test_star_shapeMethod · 0.90
test_single_pointMethod · 0.90
test_two_pointsMethod · 0.90
test_squareMethod · 0.90
test_duplicate_pointsMethod · 0.90

Calls

no outgoing calls

Tested by 13

test_point_creationMethod · 0.72
test_point_equalityMethod · 0.72
test_point_reprMethod · 0.72
test_point_hashMethod · 0.72
test_triangleMethod · 0.72
test_collinear_pointsMethod · 0.72
test_star_shapeMethod · 0.72
test_single_pointMethod · 0.72
test_two_pointsMethod · 0.72
test_squareMethod · 0.72
test_duplicate_pointsMethod · 0.72