From 03d5b2d19d33bcafdfbbac2c8fc040e26ef57f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 29 Nov 2019 16:53:41 +0200 Subject: [PATCH] unsuccessful polygon --- Karto/assignment4/draw.py | 14 +++++++++++--- Karto/assignment4/measure.py | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Karto/assignment4/draw.py b/Karto/assignment4/draw.py index 024d95c..6fefbc6 100755 --- a/Karto/assignment4/draw.py +++ b/Karto/assignment4/draw.py @@ -19,7 +19,6 @@ CONTINUOUS = (1,0) DASHDOTX2 = (10,3,2,3) DASHED = (100,20) - keliai = [ kelias( id='A-08', @@ -86,8 +85,7 @@ point_annotations = { 17: N, 18: E, 19: N, 20: S, 21: N, 22: S, 23: E, 24: N, } - -road_annotations = { 'A-08': W, 'A-05': N, 'A-03': N, 'G-11': E } +road_annotations = {'A-08':W, 'A-05':N, 'A-03':N, 'G-11':E} # implementacija fig, ax = plt.subplots() @@ -123,4 +121,14 @@ for id, kelias in keliai_l.items(): offset = road_annotations[id] ax.annotate(id, kelias.offsets[-1].coords[0], zorder=KAT0, textcoords='offset points', xytext=offset, rotation=angle) +# septynkampis +prev_dirang = float(K1)*pi/180 +step = 5*7*pi +heptagon = [np.array(Points[6].xy)] +for i in range(1, 7): + dxy = np.array([float(D1)*cos(prev_dirang), float(D1)*sin(prev_dirang)]) + heptagon.append(heptagon[i-1] + dxy) + prev_dirang += step +ax.add_patch(PolygonPatch(asPolygon(heptagon), linewidth=2, fc='grey')) + plt.show() diff --git a/Karto/assignment4/measure.py b/Karto/assignment4/measure.py index c1a87de..68861b8 100755 --- a/Karto/assignment4/measure.py +++ b/Karto/assignment4/measure.py @@ -2,6 +2,7 @@ from collections import namedtuple from decimal import Decimal as Dec from math import sin, cos, pi +import numpy as np def normalize(ang): while ang > 180: @@ -37,7 +38,7 @@ class Vertex: @property def xy(self): """xy returns a tuple of lksx and lksy coordinates""" - return (self.coords.lksx, self.coords.lksy) + return np.array([float(self.coords.lksx), float(self.coords.lksy)]) # Kategorijos KAT0, KAT1, KAT2, KAT3, KAT4 = range(5,0,-1)