Ejemplo n.º 1
0
    def BtnPressedCalc(self):
        A_y = float(self.str_Ay.get().replace(",", "."))
        A_x = float(self.str_Ax.get().replace(",", "."))
        B_y = float(self.str_By.get().replace(",", "."))
        B_x = float(self.str_Bx.get().replace(",", "."))
        M_y = float(self.str_My.get().replace(",", "."))
        M_x = float(self.str_Mx.get().replace(",", "."))
        pA = Punkt(A_y, A_x)
        pB = Punkt(B_y, B_x)
        pM = Punkt(M_y, M_x)

        if self.int_radioBSelect.get() == 0:
            t_NA = Winkel(float(self.str_TNA.get().replace(",", ".")), "gon")
            t_NM = Winkel(float(self.str_TNM.get().replace(",", ".")), "gon")
            t_NB = Winkel(float(self.str_TNB.get().replace(",", ".")), "gon")
            self.str_Alpha.set("")
            self.str_Beta.set("")
            pN = Rückwärtsschnitt.init_dir(pA, pB, pM, t_NA, t_NB,
                                           t_NM).schneiden()
        else:
            aAlpha = Winkel(float(self.str_Alpha.get().replace(",", ".")),
                            "gon")
            aBeta = Winkel(float(self.str_Beta.get().replace(",", ".")), "gon")
            self.str_TNA.set("")
            self.str_TNM.set("")
            self.str_TNB.set("")
            pN = Rückwärtsschnitt(pA, pB, pM, aAlpha, aBeta).schneiden()
        self.str_Ny.set(self.runde(pN.get_y()))
        self.str_Nx.set(self.runde(pN.get_x()))
Ejemplo n.º 2
0
    def readFile(self, filepath, sepDec=".", sepVal=","):
        with open(filepath, "r") as fh:
            lines = fh.read()
        for l in lines.splitlines():
            if l == "": 
                break
            if sepDec != ".":
                l = l.replace(sepDec, ".")
            try:
                sId, beta, s_rück, s_vor, y, x = l.split(sepVal)
                a = {}
                if beta != "":
                    a["beta"] = Winkel(float(beta), "gon")
                if s_rück != "":
                    a["s_rück"] = Strecke.init_länge(float(s_rück))
                if s_vor != "":
                    a["s_vor"] = Strecke.init_länge(float(s_vor))
                if y != "" or x != "":
                    p = Punkt(float(y), float(x), sId)
                else:
                    p = Punkt(0, 0, sId)

                if sId in self.__polygon.get_pIdList():
                    self.__polygon.update_PpointAttributebyID(sId, a)
                else:
                    self.__polygon.add_Ppointwithcoords(p, a)
            except:
                pass
            self.__parameter.update({"w_beta":Winkel(0), "w_y":0, "w_x":0})
Ejemplo n.º 3
0
 def btnBerechneErsteHAPressed(self):
     Y1 = float(self.str_y1.get().replace(",", "."))
     X1 = float(self.str_x1.get().replace(",", "."))
     t = Winkel(float(self.str_t.get().replace(",", ".")), "gon")
     s = Strecke.init_länge(float(self.str_s.get().replace(",", ".")))
     P2 = Punkt.ersteHA(Punkt(X1, Y1), s, t)
     self.str_x2.set(self.runde(P2.get_x()))
     self.str_y2.set(self.runde(P2.get_y()))
Ejemplo n.º 4
0
    def __init__(self, p0=None, p1=None, p0_status=False, p1_status=False):
        if (p0 is None):
            p0 = Punkt()
        else:
            self.p0 = deepcopy(p0)

        if (p1 is None):
            p1 = Punkt()
        else:
            self.p1 = deepcopy(p1)
Ejemplo n.º 5
0
class Transformation:
    def __init__(self, d_p0, d_p1, l_p1exclude=None):
        self._dicP0 = d_p0.get_dic()
        self._dicP1 = d_p1.get_dic()

        self.__dicP1_complete = deepcopy(self._dicP1)

        self._dicP2 = Punkt_Dic()

        self._tParameter = {}

        if l_p1exclude is not None:
            self._dicP1 = self.__dicP1_complete
            for e in l_p1exclude:
                self._dicP1.pop(e, None)

        self._l_p_ident = []
        for k in self._dicP0.keys():
            if k in self._dicP1.keys():
                self._l_p_ident.append(k)

        y_cog = 0
        x_cog = 0
        Y_cog = 0
        X_cog = 0
        for k in self._l_p_ident:
            y_cog += self._dicP0[k]["coord"].get_y()
            x_cog += self._dicP0[k]["coord"].get_x()
            Y_cog += self._dicP1[k]["coord"].get_y()
            X_cog += self._dicP1[k]["coord"].get_x()

        i = len(self._l_p_ident)
        y_cog = y_cog / i
        x_cog = x_cog / i
        Y_cog = Y_cog / i
        X_cog = X_cog / i

        self._P0_cog = Punkt(y_cog, x_cog)
        self._P1_cog = Punkt(Y_cog, X_cog)

        self._PDic0_reduced = {}
        self._PDic1_reduced = {}
        for k in self._l_p_ident:
            y_red = self._dicP0[k]["coord"].get_y() - self._P0_cog.get_y()
            x_red = self._dicP0[k]["coord"].get_x() - self._P0_cog.get_x()
            self._PDic0_reduced.update({k: Punkt(y_red, x_red)})

            Y_red = self._dicP1[k]["coord"].get_y() - self._P1_cog.get_y()
            X_red = self._dicP1[k]["coord"].get_x() - self._P1_cog.get_x()
            self._PDic1_reduced.update({k: Punkt(Y_red, X_red)})
Ejemplo n.º 6
0
    def berechne(self):
        s1 = self.__k1.get_r()
        s2 = self.__k2.get_r()

        s, t12 = Strecke(self.__k1.get_mp(), self.__k2.get_mp()).zweiteHA()
        w_a = acos((s1**2 + s**2 - s2**2) / (2 * s * s1))
        
        t1n_a = t12.get_w() + w_a
        t1n_b = t12.get_w() - w_a

        yn_a = self.__k1.get_mp().get_y() + s1 * sin(t1n_a)
        xn_a = self.__k1.get_mp().get_x() + s1 * cos(t1n_a)
        yn_b = self.__k1.get_mp().get_y() + s1 * sin(t1n_b)
        xn_b = self.__k1.get_mp().get_x() + s1 * cos(t1n_b)
        return (Punkt(yn_a,xn_a),Punkt(yn_b,xn_b))
Ejemplo n.º 7
0
 def btnBerechnePressed(self):
     Y1 = float(self.eingabeY1.get().replace(",", "."))
     X1 = float(self.eingabeX1.get().replace(",", "."))
     Y2 = float(self.eingabeY2.get().replace(",", "."))
     X2 = float(self.eingabeX2.get().replace(",", "."))
     S1 = float(self.eingabeS1.get().replace(",", "."))
     S2 = float(self.eingabeS2.get().replace(",", "."))
     p1 = Punkt(Y1, X1)
     p2 = Punkt(Y2, X2)
     k1 = Kreis(p1, S1)
     k2 = Kreis(p2, S2)
     p3, p4 = Bogenschnitt(k1, k2).berechne()
     self.ausgabeY1.set(self.runde(p3.get_y()))
     self.ausgabeX1.set(self.runde(p3.get_x()))
     self.ausgabeY2.set(self.runde(p4.get_y()))
     self.ausgabeX2.set(self.runde(p4.get_x()))
Ejemplo n.º 8
0
    def schneiden(self):
        A_y = self.__pA.get_y()
        A_x = self.__pA.get_x()
        B_y = self.__pB.get_y()
        B_x = self.__pB.get_x()
        M_y = self.__pM.get_y()
        M_x = self.__pM.get_x()
        alpha = self.__aAlpha.get_w()
        beta = self.__aBeta.get_w()

        dMA_y = A_y - M_y
        dMA_x = A_x - M_x
        dMB_y = B_y - M_y
        dMB_x = B_x - M_x

        tan_MN = (dMA_y * cot(alpha) - dMB_y * cot(beta) + (dMB_x - dMA_x)) /\
            (dMA_x * cot(alpha) - dMB_x * cot(beta) - (dMB_y - dMA_y))

        dMN_x = ((dMA_y + dMA_x * cot(alpha)) * tan_MN + (dMA_x - dMA_y * cot(alpha))) /\
            (1+tan_MN**2)
        dMN_y = dMN_x * tan_MN

        N_y = M_y + dMN_y
        N_x = M_x + dMN_x

        return Punkt(N_y, N_x)
Ejemplo n.º 9
0
    def __init__(self, d_p0, d_p1, l_p1exclude):
        super().__init__(d_p0, d_p1, l_p1exclude)

        nenner = 0
        o_zähler = 0
        a_zähler = 0
        for k in self._l_p_ident:
            o_zähler += self._PDic0_reduced[k].get_x() * self._PDic1_reduced[k].get_y() -\
                self._PDic0_reduced[k].get_y() * self._PDic1_reduced[k].get_x()
            nenner += self._PDic0_reduced[k].get_x(
            )**2 + self._PDic0_reduced[k].get_y()**2
            a_zähler += self._PDic0_reduced[k].get_x() * self._PDic1_reduced[k].get_x() +\
                self._PDic0_reduced[k].get_y() * self._PDic1_reduced[k].get_y()

        a = a_zähler / nenner
        o = o_zähler / nenner
        m = sqrt(a**2 + o**2)
        epsilon = atan(o / a)
        Y0 = self._P1_cog.get_y(
        ) - a * self._P0_cog.get_y() - o * self._P0_cog.get_x()
        X0 = self._P1_cog.get_x(
        ) - a * self._P0_cog.get_x() + o * self._P0_cog.get_y()

        self._tParameter.update({"m_Y": m})
        self._tParameter.update({"rot_Y": epsilon})
        self._tParameter.update({"Y0": Y0})
        self._tParameter.update({"X0": X0})

        dicPTrans = {}
        for k, v in self._dicP0.items():
            y = v["coord"].get_y()
            x = v["coord"].get_x()
            pId = v["coord"].get_id()
            Y = Y0 + a * y + o * x
            X = X0 + a * x - o * y
            pTransformiert = {"coord": Punkt(Y, X, pId)}
            dicPTrans.update({pId: pTransformiert})
            if k in self._l_p_ident:
                wy = -Y0 - a * self._dicP0[k]["coord"].get_y(
                ) - o * self._dicP0[k]["coord"].get_x(
                ) + self._dicP1[k]["coord"].get_y()
                wx = -X0 - a * self._dicP0[k]["coord"].get_x(
                ) + o * self._dicP0[k]["coord"].get_y(
                ) + self._dicP1[k]["coord"].get_x()
                dicPTrans[k].update({"w": Punkt(wy, wx, "w")})

        self._dicP2.set_dic(dicPTrans)
Ejemplo n.º 10
0
 def BtnPressedCalc(self):
     p1_y = float(self.str_1y.get().replace(",", "."))
     p1_x = float(self.str_1x.get().replace(",", "."))
     p2_y = float(self.str_2y.get().replace(",", "."))
     p2_x = float(self.str_2x.get().replace(",", "."))
     p3_y = float(self.str_3y.get().replace(",", "."))
     p3_x = float(self.str_3x.get().replace(",", "."))
     p4_y = float(self.str_4y.get().replace(",", "."))
     p4_x = float(self.str_4x.get().replace(",", "."))
     p1 = Punkt(p1_y, p1_x)
     p2 = Punkt(p2_y, p2_x)
     p3 = Punkt(p3_y, p3_x)
     p4 = Punkt(p4_y, p4_x)
     tPhi = Winkel(float(self.str_Tphi.get().replace(",", ".")), "gon")
     tPsi = Winkel(float(self.str_Tpsi.get().replace(",", ".")), "gon")
     pN = Vorwärtsschnitt(p1, p2, p3, p4, tPhi, tPsi).schneiden()
     self.str_Ny.set(self.runde(pN.get_y()))
     self.str_Nx.set(self.runde(pN.get_x()))
Ejemplo n.º 11
0
    def schneiden(self):
        p1_y = self.__p1.get_y()
        p1_x = self.__p1.get_x()
        p2_y = self.__p2.get_y()
        p2_x = self.__p2.get_x()

        t_41 = Strecke(self.__p1, self.__p4).zweiteHA()[1].get_w()
        t_1N = t_41 + self.__tPhi.get_w()
        tan_1N = tan(t_1N)

        t_23 = Strecke(self.__p2, self.__p3).zweiteHA()[1].get_w()
        t_2N = t_23 + self.__tPsi.get_w()
        tan_2N = tan(t_2N)

        pN_x = p1_x + ((p2_y - p1_y) -
                       (p2_x - p1_x) * tan_2N) / (tan_1N - tan_2N)
        pN_y = p1_y + (pN_x - p1_x) * tan_1N

        return Punkt(pN_y, pN_x)
Ejemplo n.º 12
0
    def berechneRingpolygon(self):  # Für Außenwinkel
        n = self.__polygon.get_counter()    # testdata: 6:(p1...p6)
        beta_summe = 0
        s_summe = 0
        for pId in self.__polygon.get_pIdList():
            beta_summe += self.__polygon.get_PpointbyPId(pId)["beta"].get_w()
            s_summe += self.__polygon.get_PpointbyPId(pId)["s_vor"].länge()
        w_beta = Winkel((n+2) * pi - beta_summe)
        w_beta_n = Winkel(w_beta.get_w() / n)

        # r, dy, dx
        dy_summe = 0
        dx_summe = 0
        for i in range(n):  # testdata: Standpunkt p1...p6
            if i == 0:
                r = Winkel(0)
            else:
                r = Winkel(self.__polygon.get_PpointbyNr(i-1)["r"].get_w() + self.__polygon.get_PpointbyNr(i)["beta"].get_w() + w_beta_n.get_w() - pi)
            dy = sin(r.get_w()) * self.__polygon.get_PpointbyNr(i)["s_vor"].länge()
            dx = cos(r.get_w()) * self.__polygon.get_PpointbyNr(i)["s_vor"].länge()
            dy_summe += dy
            dx_summe += dx
            self.__polygon.update_PpointAttributebyNr(i, {"r": r, "dy": dy, "dx": dx})

        w_y_s = - dy_summe / s_summe
        w_x_s = - dx_summe / s_summe
        for i in range(1,n):    # testdata: Standpunkt p2...p6
            s = self.__polygon.get_PpointbyNr(i-1)["s_vor"].länge()
            r = self.__polygon.get_PpointbyNr(i-1)["r"].get_w()

            dy = self.__polygon.get_PpointbyNr(i-1)["dy"] + w_y_s * s
            dx = self.__polygon.get_PpointbyNr(i-1)["dx"] + w_x_s * s
            y = self.__polygon.get_PpointbyNr(i-1)["coord"].get_y()
            x = self.__polygon.get_PpointbyNr(i-1)["coord"].get_x()
            pId = self.__polygon.get_PpointbyNr(i-1)["coord"].get_id()

            self.__polygon.update_PpointAttributebyNr(i, {"coord": Punkt(y+dy, x+dx, pId)})
            self.__parameter.update({"w_beta":w_beta, "w_y":dy_summe, "w_x":dx_summe})
Ejemplo n.º 13
0
 def init_koor(cls, p0_y, p0_x, p1_y, p1_x):
     p0 = Punkt(p0_y, p0_x)
     p1 = Punkt(p1_y, p1_x)
     return cls(p0, p1, True, True)
Ejemplo n.º 14
0
 def init_länge2(cls, p0, l):
     p1 = Punkt(p0.get_y(), p0.get_x() + l)
     return cls(p0, p1, True, False)
Ejemplo n.º 15
0
 def init_länge(cls, l):
     p0 = Punkt()
     p1 = Punkt(0, l)
     return cls(p0, p1, False, False)
Ejemplo n.º 16
0
                if (isinstance(v, dict)):
                    objekt = getattr(self, k)
                    objekt.set_json(v)
                else:
                    setattr(self, k, v)

    @classmethod
    def init_jsonKoor(cls, d):
        p0 = Punkt.init_json(d["p0"])
        p1 = Punkt.init_json(d["p1"])
        return cls(p0, p1)


if __name__ == "__main__":

    p0 = Punkt(0, 0)
    p1 = Punkt(0, 2)

    s = Strecke(p0, p1)
    d, t = s.zweiteHA()
    print(s, d, t)

    # s1 = Strecke.init_länge(3)
    # s2 = Strecke.init_länge2(p1, 3)
    # s3 = Strecke.init_koor(1.2, 3.4, 5.6, 7.8)
    # print(s1, "\t", s2, "\t", s3)

    #print(json.dumps(s, default=lambda objekt: objekt.get_json(),sort_keys=True, indent=4))

    jstr = """
{
Ejemplo n.º 17
0
    sys.path.append(".")

from datentyp.punkt import Punkt


class Kreis:
    def __init__(self, mp, r):
        self.__mp = mp
        self.__r = r

    def get_mp(self):
        return self.__mp

    def get_r(self):
        return self.__r

    def set_mp(self, mp):
        self.__mp = mp

    def set_r(self, r):
        self.__r = r

    def __str__(self):
        return "Kreis MP: " + str(self.__mp) + " Radius: " + str(self.__r)


if __name__ == "__main__":
    mipu = Punkt(1, 1)
    c = Kreis(mipu, 1)
    print(c)
Ejemplo n.º 18
0
def erste(p1, p12_s, p12_t):
    __y2 = p1.get_y() + (p12_s.länge() * sin(p12_t.get_w()))
    __x2 = p1.get_x() + (p12_s.länge() * cos(p12_t.get_w()))
    return Punkt(__y2, __x2)
Ejemplo n.º 19
0
        dMN_x = ((dMA_y + dMA_x * cot(alpha)) * tan_MN + (dMA_x - dMA_y * cot(alpha))) /\
            (1+tan_MN**2)
        dMN_y = dMN_x * tan_MN

        N_y = M_y + dMN_y
        N_x = M_x + dMN_x

        return Punkt(N_y, N_x)


def cot(a):
    return (1 / tan(a))


if __name__ == "__main__":
    pA = Punkt(46867.94, 5537.00)
    pM = Punkt(49666.56, 4448.58)
    pB = Punkt(51293.86, 6365.89)
    riwiA = Winkel(66.8117, "gon")
    riwiM = Winkel(362.8516, "gon")
    riwiB = Winkel(294.7845, "gon")
    # pA = Punkt(209.13, 193.4)
    # pM = Punkt(420.68, 639.27)
    # pB = Punkt(578.47, 198.38)
    # riwiA = 0.0
    # riwiM = 116.895
    # riwiB = 284.622

    pRes = Rückwärtsschnitt.init_dir(pA, pB, pM, riwiA, riwiB,
                                     riwiM).schneiden()
    print(pRes)
Ejemplo n.º 20
0
    def __init__(self, d_p0, d_p1, l_p1exclude):
        super().__init__(d_p0, d_p1, l_p1exclude)

        xX = yX = xy = xY = yY = yy = xx = 0
        for k in self._l_p_ident:
            xX += self._PDic0_reduced[k].get_x(
            ) * self._PDic1_reduced[k].get_x()
            yX += self._PDic0_reduced[k].get_y(
            ) * self._PDic1_reduced[k].get_x()
            xy += self._PDic0_reduced[k].get_x(
            ) * self._PDic0_reduced[k].get_y()
            xY += self._PDic0_reduced[k].get_x(
            ) * self._PDic1_reduced[k].get_y()
            yY += self._PDic0_reduced[k].get_y(
            ) * self._PDic1_reduced[k].get_y()
            yy += self._PDic0_reduced[k].get_y()**2
            xx += self._PDic0_reduced[k].get_x()**2
        N = xx * yy - xy**2

        a1 = (xX * yy - yX * xy) / N
        a2 = (xX * xy - yX * xx) / N
        a3 = (yY * xx - xY * xy) / N
        a4 = (xY * yy - yY * xy) / N

        m_X = sqrt(a1**2 + a4**2)
        m_Y = sqrt(a2**2 + a3**2)
        alpha = atan(a4 / a1)
        beta = atan(a2 / a3)

        Y0 = self._P1_cog.get_y(
        ) - a3 * self._P0_cog.get_y() - a4 * self._P0_cog.get_x()
        X0 = self._P1_cog.get_x(
        ) - a1 * self._P0_cog.get_x() + a2 * self._P0_cog.get_y()

        self._tParameter.update({"m_X": m_X})
        self._tParameter.update({"m_Y": m_Y})
        self._tParameter.update({"rot_X": alpha})
        self._tParameter.update({"rot_Y": beta})
        self._tParameter.update({"Y0": Y0})
        self._tParameter.update({"X0": X0})

        dicPTrans = {}
        for k, v in self._dicP0.items():
            y = v["coord"].get_y()
            x = v["coord"].get_x()
            pId = v["coord"].get_id()
            Y = Y0 + a3 * y + a4 * x
            X = X0 + a1 * x - a2 * y
            pTransformiert = {"coord": Punkt(Y, X, pId)}
            dicPTrans.update({pId: pTransformiert})
            if k in self._l_p_ident:
                wy = -Y0 - a3 * self._dicP0[k]["coord"].get_y(
                ) - a4 * self._dicP0[k]["coord"].get_x(
                ) + self._dicP1[k]["coord"].get_y()
                wx = -X0 - a1 * self._dicP0[k]["coord"].get_x(
                ) + a2 * self._dicP0[k]["coord"].get_y(
                ) + self._dicP1[k]["coord"].get_x()
                #w = {"y":Strecke.init_länge(wy), "x":Strecke.init_länge(wx)}
                dicPTrans[k].update({"w": Punkt(wy, wx, "w")})

        self._dicP2.set_dic(dicPTrans)
Ejemplo n.º 21
0
    def berechnePolygonzug(self):
        t_0 = Strecke(self.__polygon.get_PpointbyNr(0)["coord"], self.__polygon.get_PpointbyNr(1)["coord"]).zweiteHA()[1]
        self.__polygon.update_PpointAttributebyNr(0, {"t_0": t_0})
        t_n = Strecke(self.__polygon.get_PpointbyNr(-2)["coord"], self.__polygon.get_PpointbyNr(-1)["coord"]).zweiteHA()[1]
        self.__polygon.update_PpointAttributebyNr(-2, {"t_n": t_n})

        # w_beta
        n = self.__polygon.get_counter()-2  # Anzahl Messstandpunkte 5:(p0...p6)-2
        beta_summe = 0
        for i in range(1, n+1):  # testdata: Standpunkt p1...p6
            beta_summe += self.__polygon.get_PpointbyNr(i)["beta"].get_w()

        w_beta = self.__polygon.get_PpointbyNr(-2)["t_n"].get_w() - (self.__polygon.get_PpointbyNr(0)["t_0"].get_w() + beta_summe - (n*pi))
        if w_beta > pi:
            w_beta = 2*pi - w_beta
        w_beta = Winkel(w_beta)
        w_beta_n = Winkel(w_beta.get_w() / n)

        # r
        for i in range(1, n+1):  # testdata: Standpunkt p1...p6
            beta = self.__polygon.get_PpointbyNr(i)["beta"].get_w()
            if i == 1:
                r = self.__polygon.get_PpointbyNr(0)["t_0"].get_w() + beta + w_beta_n.get_w() + pi
            else:
                r = self.__polygon.get_PpointbyNr(i-1)["r"].get_w() + beta + w_beta_n.get_w() + pi
            if r < (2*pi):
                r += 2*pi
            elif r > (2*pi):
                r -= 2*pi
            self.__polygon.update_PpointAttributebyNr(i, {"r": Winkel(r)})

        # dy, dx Koordinatenunterschiede
        dy_summe = 0
        dx_summe = 0
        s_summe = 0
        for i in range(1, n):    # testdata: Standpunkt p1...p4
            s = self.__polygon.get_PpointbyNr(i)["s_vor"].länge()
            dy = s * sin(self.__polygon.get_PpointbyNr(i)["r"].get_w())
            dx = s * cos(self.__polygon.get_PpointbyNr(i)["r"].get_w())
            dy_summe += dy
            dx_summe += dx
            self.__polygon.update_PpointAttributebyNr(i, {"dy": dy})
            self.__polygon.update_PpointAttributebyNr(i, {"dx": dx})
            s_summe += s

        # w_y, w_x Koordinatenabschlussverbesserung
        w_y = (self.__polygon.get_PpointbyNr(-2)["coord"].get_y() - self.__polygon.get_PpointbyNr(1)["coord"].get_y()) - dy_summe
        w_x = (self.__polygon.get_PpointbyNr(-2)["coord"].get_x() - self.__polygon.get_PpointbyNr(1)["coord"].get_x()) - dx_summe
        w_y_s = (w_y / s_summe)
        w_x_s = (w_x / s_summe)

        # y,x Koordinaten
        for i in range(1, n-1):  # testdata: Standpunkt p1...p3
            s = self.__polygon.get_PpointbyNr(i)["s_vor"].länge()
            dy = self.__polygon.get_PpointbyNr(i)["dy"]
            dx = self.__polygon.get_PpointbyNr(i)["dx"]
            v_y = w_y_s * s
            v_x = w_x_s * s
            y = self.__polygon.get_PpointbyNr(i)["coord"].get_y() + dy + v_y
            x = self.__polygon.get_PpointbyNr(i)["coord"].get_x() + dx + v_x
            self.__polygon.update_PpointAttributebyNr(i+1, {"coord": Punkt(y, x)})
        self.__parameter.update({"w_beta":w_beta, "w_y":w_y, "w_x":w_x})
Ejemplo n.º 22
0
    def __init__(self, k1, k2):
        self.__k1 = k1
        self.__k2 = k2

    def berechne(self):
        s1 = self.__k1.get_r()
        s2 = self.__k2.get_r()

        s, t12 = Strecke(self.__k1.get_mp(), self.__k2.get_mp()).zweiteHA()
        w_a = acos((s1**2 + s**2 - s2**2) / (2 * s * s1))
        
        t1n_a = t12.get_w() + w_a
        t1n_b = t12.get_w() - w_a

        yn_a = self.__k1.get_mp().get_y() + s1 * sin(t1n_a)
        xn_a = self.__k1.get_mp().get_x() + s1 * cos(t1n_a)
        yn_b = self.__k1.get_mp().get_y() + s1 * sin(t1n_b)
        xn_b = self.__k1.get_mp().get_x() + s1 * cos(t1n_b)
        return (Punkt(yn_a,xn_a),Punkt(yn_b,xn_b))

if __name__ == "__main__":
    p1 = Punkt(328.76, 1207.85)
    p2 = Punkt(925.04, 954.33)
    # s1 = Strecke.init_länge2(p1, 294.33)
    # s2 = Strecke.init_länge2(p2, 506.42)

    k1 = Kreis(p1, 294.33)
    k2 = Kreis(p2, 506.42)

    p_res1,p_res2 = Bogenschnitt(k1, k2).berechne()
    print(p_res1, "\n" ,p_res2)
Ejemplo n.º 23
0
                            indent=4)
        pIdL_j = json.dumps(self.__pIdList)
        return {"pDic": pDic_j, "pIdL": pIdL_j}

    def set_json(self, s):
        p_j = json.loads(s)
        self.__PDic.from_jsonPoly(p_j["pDic"])
        self.__pIdList = p_j["pIdL"]

    def clean(self):
        self.__pIdList.clear()
        self.__PDic.clear()


if __name__ == "__main__":
    from datentyp.winkel import Winkel
    from datentyp.strecke import Strecke

    p0 = Punkt(1, 1, "p01")

    dir01 = Winkel(50, "gon")
    dist01 = Strecke.init_länge(3)

    poly = Polygon()
    poly.add_Ppointwithcoords(p0)
    poly.add_NextPointByDirDist(dir01, dist01)
    poly.add_NextPointByDirDist(dir01, dist01)
    poly.update_PpointAttributebyNr(2, {"test": 1235})

    print(poly.get_PpointbyNr(2))
Ejemplo n.º 24
0
 def init_jsonKoor(cls, d):
     p0 = Punkt.init_json(d["p0"])
     p1 = Punkt.init_json(d["p1"])
     return cls(p0, p1)
Ejemplo n.º 25
0
    def schneiden(self):
        p1_y = self.__p1.get_y()
        p1_x = self.__p1.get_x()
        p2_y = self.__p2.get_y()
        p2_x = self.__p2.get_x()

        t_41 = Strecke(self.__p1, self.__p4).zweiteHA()[1].get_w()
        t_1N = t_41 + self.__tPhi.get_w()
        tan_1N = tan(t_1N)

        t_23 = Strecke(self.__p2, self.__p3).zweiteHA()[1].get_w()
        t_2N = t_23 + self.__tPsi.get_w()
        tan_2N = tan(t_2N)

        pN_x = p1_x + ((p2_y - p1_y) -
                       (p2_x - p1_x) * tan_2N) / (tan_1N - tan_2N)
        pN_y = p1_y + (pN_x - p1_x) * tan_1N

        return Punkt(pN_y, pN_x)


if __name__ == "__main__":
    p1 = Punkt(24681.92, 90831.87)
    p4 = Punkt(23231.58, 91422.92)
    p2 = Punkt(24877.72, 89251.09)
    p3 = Punkt(22526.65, 89150.52)
    tPhi = Winkel(331.6174, "gon")
    tPsi = Winkel(60.7510, "gon")
    pN = Vorwärtsschnitt(p1, p2, p3, p4, tPhi, tPsi).schneiden()
    print(pN)
Ejemplo n.º 26
0
        "Nachname": "Golly",
        "Vorname": "Andreas"
    }
}"""

j_d = json.loads(j_s)
print(json.dumps(j_d, sort_keys=True, indent=4))


# with open("../testdata/json1.csv") as fh:
#     j_d2 = json.loads(fh)
# print(json.dumps(j_d2, sort_keys=True, indent=4)) 

k = ssl._create_unverified_context()
with urllib.request.urlopen("https://py.webmapping.eu/kfz.json",context=k) as j_url:
    j_d3 = json.loads(j_url.read().decode())
print(json.dumps(j_d3, sort_keys=True, indent=4))

with open(r"C:\Users\hir0\OneDrive\VSC-Workspace\PGA\testdata\json_url_output.json", "w") as fh_w:
    json.dump(j_d3, fh_w)
    
p = Punkt(1, 2)
print(p.__dict__)

with open(r"C:\Users\hir0\OneDrive\VSC-Workspace\PGA\testdata\json_punkt_output.json", "w") as fh_w:
    json.dumps(p, fh_w, default=Punkt.get_json())

p2 = Punkt()
with open(r"C:\Users\hir0\OneDrive\VSC-Workspace\PGA\testdata\json_punkt_output.json") as fh_r:
    p2.set_json(json.dumps(fh_r))