def _mode_curve(self, index): """Return""" rad, center = self.typeline[index].split(",") rad = float(rad[1:]) center = float(center) pcenter = self.plant.get_roadpoint(self.pks[index] + center) pc_d = pcenter.parallel(self.dist[index] + rad, self.g90) pstart = self.plant.get_roadpoint(self.pks[index]) distx = self._distx(rad, pc_d, pstart) p1_d = pstart.parallel(distx, self.g90) pend = self.plant.get_roadpoint(self.pks[index + 1]) distx = self._distx(rad, pc_d, pend) p2_d = pend.parallel(distx, self.g90) az1 = pc_d.azimuth(p1_d) az2 = pc_d.azimuth(p2_d) alpha = abs(az2 - az1) if alpha > math.pi: alpha = 2 * math.pi - alpha curve = Base.Curve(self._intbool() * rad, alpha, az1, pc_d) return curve
def _curve_high_low(self, pnt_center, pnt_1, dat1, dat2): """ Return """ # R1>R2 # Calculamos los puntos de tangencia de la clotoide con los dos circulo out_local = Base.cloth_local(dat1['radio'], dat1['a_out']) in_local = Base.cloth_local(dat2['radio'], dat2['a_in']) azi_in = pnt_center.azimuth(pnt_1) alpha = dat2['dc_'] / dat2['radio'] if dat1['radio'] > 0 and dat2['radio'] > 0: g90 = math.pi / 2 elif dat1['radio'] < 0 and dat2['radio'] < 0: g90 = -math.pi / 2 else: raise ValueError( "Error: For change the radio sing a straight must be \ between the radios") # return [None, None, None] pnt_t1 = pnt_center.project(abs(dat1['radio'] + out_local['y_o']), azi_in - out_local['tau']) pnt_t2 = pnt_t1.project(in_local['x_o'] - out_local['x_o'], azi_in - out_local['tau'] + g90) pnt_ad2 = pnt_t1.project(out_local['x_o'], azi_in - out_local['tau'] + g90) pnt_c2 = pnt_t2.project(abs(dat2['radio'] + in_local['y_o']), azi_in - out_local['tau'] + 2 * g90) pnt_ar2 = pnt_c2.project( abs(dat2['radio'], azi_in - out_local['tau'] + in_local['tau'])) pnt_ra2 = pnt_c2.project( abs(dat2['radio']), azi_in - out_local['tau'] + in_local['tau'] + alpha) if dat2['a_in'] != 0: cloth = Base.Clothoid(dat2['a_in'], dat2['radio'], pnt_ad2.azimuth(pnt_t2), 'in', None, pnt_c2) self.list_aligns.append() self.straight_curve_lengs.append(cloth.length()) curve = Base.Curve(dat2['radio'], alpha, pnt_c2.azimuth(pnt_ar2), pnt_c2) self.list_aligns.append(curve) self.straight_curve_lengs.append(curve.length()) return pnt_c2, pnt_ra2, Base.Straight(pnt_ad2, pnt_t1)
def _curve_low_high(self, pnt_center, pnt_1, dat1, dat2): """Return""" # R1<R2 out_local = Base.cloth_local(dat1["radio"], dat1["a_out"]) in_local = Base.cloth_local(dat2["radio"], dat2["a_in"]) azi_in = pnt_center.azimuth(pnt_1) alpha = dat2["dc_"] / dat2["radio"] if dat1["radio"] > 0 and dat2["radio"] > 0: g90 = math.pi / 2 elif dat1["radio"] < 0 and dat2["radio"] < 0: g90 = -math.pi / 2 else: raise ValueError("Error: For change the radio sing a straight \ must be between the radios") # return (None, None, None) pnt_t1 = pnt_center.project(abs(dat1["radio"] + out_local["y_o"]), azi_in + out_local["tau"]) pnt_t2 = pnt_t1.project(in_local["x_o"] - out_local["x_o"], azi_in + out_local["tau"] + g90) pnt_da1 = pnt_t1.project(out_local["x_o"], azi_in + out_local["tau"] + g90) pnt_c2 = pnt_t2.project(abs(dat2["radio"] + in_local["y_o"]), azi_in + out_local["tau"] + 2 * g90) pnt_ra2 = pnt_c2.project( abs(dat2["radio"]), azi_in + out_local["tau"] - in_local["tau"] + alpha) if dat1["a_out"] != 0: cloth = Base.Clothoid( dat1["a_out"], dat1["radio"], pnt_t1.azimuth(pnt_da1), "out", None, pnt_c2, ) self.list_aligns.append(cloth) self.straight_curve_lengs.append(cloth.length()) curve = Base.Curve(dat2["radio"], alpha, pnt_c2.azimuth(pnt_ra2), pnt_c2) self.list_aligns.append(curve) self.straight_curve_lengs.append(curve.length()) return pnt_c2, pnt_ra2, Base.Straight(pnt_t1, pnt_da1)
def _init_align(self): """ Return """ local2_in = False local2_out = False if self.radio != 0: self.in_local = Base.cloth_local(self.radio, self.a_in) self.out_local = Base.cloth_local(self.radio, self.a_out) alpha = self._alpha() else: alpha = 0 p_center = self._center() if self.dat1['a_out'] < 0 and self.radio != 0: local2_out = Base.cloth_local(self.dat1['radio'], self.dat1['a_out']) self.cloth_in = Base.Clothoid(self.a_in, self.radio, self.recta1.azimuth(), 'in', local2_out, p_center) self.recta1.pend = self.cloth_in.pnt_d if self.dat1['a_out'] < 0 and self.radio != 0: self.recta1.pstart = self.cloth_in.pnt_p if self.radio == 0: az_ini = self.recta1.azimuth() else: az_ini = Base.azimut(p_center, self.cloth_in.pnt_r) self.curve = Base.Curve(self.radio, alpha, az_ini, p_center) if self.dat2['a_in'] < 0: local2_in = Base.cloth_local(self.dat2['radio'], self.dat2['a_in']) self.cloth_out = Base.Clothoid(self.a_out, self.radio, self.recta2.azimuth(), 'out', local2_in, p_center) self.straight = Base.Straight(self.recta1.pstart, self.recta1.pend, None, None)
def _staight_curve(self, pnt_center, pnt_1, dat1, dat2): """ Return """ # R1 = 0 y R2 != 0 in_local = Base.cloth_local(dat2['radio'], dat2['a_in']) alpha = dat2['dc_'] / dat2['radio'] azi_in = pnt_center.azimuth(pnt_1) pnt_ad = pnt_center.project(dat1['lr_'], azi_in) pnt_t2 = pnt_ad.project(in_local['x_o'], azi_in) if dat2['radio'] > 0: g90 = math.pi / 2 else: g90 = -math.pi / 2 pnt_c2 = pnt_t2.project(abs(dat2['radio'] + in_local['y_o']), azi_in + g90) pnt_c2.npk = dat1['lr_'] az_in_c = azi_in + in_local['tau'] - g90 if az_in_c < 0: az_in_c += 2 * math.pi pnt_ra = pnt_c2.project(abs(dat2['radio']), az_in_c + alpha) pnt_ra.npk = dat1['lr_'] if dat2['a_in'] != 0: cloth = Base.Clothoid(dat2['a_in'], dat2['radio'], azi_in, 'in', None, pnt_c2) self.list_aligns.append(cloth) self.straight_curve_lengs.append(cloth.length()) curve = Base.Curve(dat2['radio'], abs(alpha), az_in_c, pnt_c2) self.list_aligns.append(curve) self.straight_curve_lengs.append(curve.length()) return pnt_c2, pnt_ra, Base.Straight(pnt_center, pnt_ad)