Add sample_to_graph() to make code easier to read
This commit is contained in:
parent
d83e52acb7
commit
72d8195943
1 changed files with 11 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue