diff --git a/lib/xmet/hodograph.py b/lib/xmet/hodograph.py index b3552ee..008d770 100644 --- a/lib/xmet/hodograph.py +++ b/lib/xmet/hodograph.py @@ -29,12 +29,20 @@ class Hodograph(): self.height = min(width, height) self.radius = min(width, height) * self.zoom + def sample_to_graph(self, wind_speed: dir, wind_dir: float) -> tuple: + r = self.radius * (wind_speed / WIND_SPEED_MAX) + + x = r * math.cos(radians(wind_dir)) + y = r * math.sin(radians(wind_dir)) + + return x, y + def sample_to_screen(self, wind_speed: dir, wind_dir: float) -> tuple: - r = self.radius * min(wind_speed, WIND_SPEED_MAX) / WIND_SPEED_MAX + gx, gy = self.sample_to_graph(wind_speed, wind_dir) return ( - self.offset_x * self.width + r * math.cos(radians(wind_dir)), - self.offset_y * self.height + r * math.sin(radians(wind_dir)) + self.offset_x * self.width + gx, + self.offset_y * self.height + gy ) def draw_speed_lines(self, cr: cairo.Context, x, y):