def updated(self, ep): if self.p1_point.is_set: if self.p_bottom_corner.is_set: v = (self.p_bottom_corner.get() - self.p1_point.get()) mag = v.mag() v = v.norm() self.__theta = v.angle() self._model.pin_spacing = mag / (self._model.side1_pins - 1) self.v_base = Vec2.fromPolar(self.__theta, 1) self.v_vert = Vec2(-self.v_base.y, self.v_base.x).norm() p_edge_center = self.v_base * self._model.pin_spacing * (self._model.side1_pins - 1) / 2 if self.p_side_3_1.is_set: dv = self.p_side_3_1.get() - self.p1_point.get() v, _ = project_point_line(dv, Point2(0,0), self.v_vert, False) self._model.dim_2_pincenter = v.mag() self.center = self.v_vert * self._model.dim_2_pincenter / 2 + p_edge_center + self.p1_point.get() if self.p_side_2_1.is_set: v, _ = project_point_line(self.p_side_2_1.get() - self.center, Point2(0,0), self.v_base, False) self._model.dim_1_pincenter = v.mag() * 2
def updated(self, ep): if self.p1_point.is_set: if self.p_bottom_corner.is_set: v = (self.p_bottom_corner.get() - self.p1_point.get()) mag = v.mag() v = v.norm() self.__theta = v.angle() self._model.pin_spacing = mag / (self._model.side1_pins - 1) self.v_base = Vec2.fromPolar(self.__theta, 1) self.v_vert = Vec2(-self.v_base.y, self.v_base.x).norm() p_edge_center = self.v_base * self._model.pin_spacing * ( self._model.side1_pins - 1) / 2 if self.p_side_3_1.is_set: dv = self.p_side_3_1.get() - self.p1_point.get() v, _ = project_point_line(dv, Point2(0, 0), self.v_vert, False) self._model.dim_2_pincenter = v.mag() self.center = self.v_vert * self._model.dim_2_pincenter / 2 + p_edge_center + self.p1_point.get( ) if self.p_side_2_1.is_set: v, _ = project_point_line(self.p_side_2_1.get() - self.center, Point2(0, 0), self.v_base, False) self._model.dim_1_pincenter = v.mag() * 2
def __update_pads(self): if self.__pads: return v = Vec2.fromPolar(0, self.pin_d) td = 1 if self.body_type in (PassiveBodyType.TH_AXIAL, PassiveBodyType.TH_RADIAL) else 0 if td: y = x = self.pin_corner_vec.x * 2 else: y = self.pin_corner_vec.y * 2 x = self.pin_corner_vec.x * 2 self.__pads = [Pad(self, 1, v, 0, y, x, td, self.side), Pad(self, 2, -v, 0, y, x, td, self.side)]
def __update_pads(self): if self.__pads: return v = Vec2.fromPolar(0, self.pin_d) td = 1 if self.body_type in (PassiveBodyType.TH_AXIAL, PassiveBodyType.TH_RADIAL) else 0 if td: y = x = self.pin_corner_vec.x *2 else: y = self.pin_corner_vec.y * 2 x = self.pin_corner_vec.x * 2 self.__pads = [ Pad(self, 1, v, 0, y, x, td, self.side), Pad(self, 2, -v, 0, y, x, td, self.side), ]
def other_point(): return Vec2.fromPolar(self.theta, self.model.pin_d)
def corner_offset(): mag = self._model.pin_spacing * (self._model.side1_pins - 1) return Vec2.fromPolar(self.__theta, mag)