Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created May 26, 2022 11:40
Show Gist options
  • Save MartinThoma/f78794ee6a64747c20a52b2d7fcdd56a to your computer and use it in GitHub Desktop.
Save MartinThoma/f78794ee6a64747c20a52b2d7fcdd56a to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
@dataclass
class Point:
x: float
y: float
@dataclass
class Line:
p1: Point
p2: Point
def position(self, p: float) -> Point:
return Point(
self.p1.x + (self.p2.x - self.p1.x) * p,
self.p1.y + (self.p2.y - self.p1.y) * p,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment