Ejemplo n.º 1
0
Archivo: Drawable.py Proyecto: ChMcg/CG
 def gen_lines(self) -> List[QtCore.QLine]:
     ret = []
     for connection in self.conn:
         a, b = connection
         A = (self.points[a-1] + v3(self.center)).to_v2().to_QPoint()
         B = (self.points[b-1] + v3(self.center)).to_v2().to_QPoint()
         ret.append(QtCore.QLine(A, B))
     return ret
Ejemplo n.º 2
0
Archivo: lab_3.py Proyecto: ChMcg/CG
 def set_surface_points(self, points: List[list[int]]):
     a, b, c, d = points
     new_points = [[v3(a), v3(b)], [v3(c), v3(d)]]
     self.surface_points = new_points
     # self.surface = BilinearSurface(new_points)
     # self.recalc()
     self.rotate(*self.current_rotation)
     self.repaint()
Ejemplo n.º 3
0
Archivo: Drawable.py Proyecto: ChMcg/CG
 def __init__(self, length: int, center: Tuple[int, int], kind: AxisType):
     self.length = length
     self.center = v3((*center, 0))
     if kind is AxisType.X:
         self.point = v3((length, 0, 0))
         self.label = "x"
     if kind is AxisType.Y:
         self.point = v3((0, length, 0))
         self.label = "y"
     if kind is AxisType.Z:
         self.point = v3((0, 0, length))
         self.label = "z"
Ejemplo n.º 4
0
class BilinearSurface():
    default_points = [[
        v3((-150, -150, 0)),
        v3((-150, 150, 0)),
    ], [v3((150, -150, 0)), v3((150, 150, 0))]]

    def __init__(self, points: List[v3] = default_points):
        self.m = matrix(points)

    def calculate(self, u: float, w: float):
        a = matrix([1 - u, u])
        b = matrix([[1 - w], [w]])
        m: matrix = a * self.m * b
        return v3.from_matrix(m.item(0, 0))
Ejemplo n.º 5
0
Archivo: Drawable.py Proyecto: ChMcg/CG
 def generate(self, side: int, center: Tuple[int, int, int]) -> List[v3]:
     hs = side // 2
     ret = [
         v3((-hs,  hs, -hs)),
         v3((-hs,  hs,  hs)),
         v3(( hs,  hs,  hs)),
         v3(( hs,  hs, -hs)),
         v3((-hs, -hs, -hs)),
         v3((-hs, -hs,  hs)),
         v3(( hs, -hs,  hs)),
         v3(( hs, -hs, -hs))
     ]
     return ret
Ejemplo n.º 6
0
 def generate_new_lines(self):
     self.lines.clear()
     self.active_lines.clear()
     max_l = 50
     t = 1
     for i in range(100):
         x, y = [
             randint(-self.w//2 + t*max_l, self.w // 2 - t*max_l),
             randint(-self.h//2 + t*max_l, self.h // 2 - t*max_l)
         ]
         offset = v2([x, y])
         a = v2([0, 0]) + offset
         b = v3([randint(10, self.max_l), 0, 0]).rotate(0, 0, randint(0, 360)).to_v2() + offset
         self.lines.append(
             Line(a, b)
         )
     self.repaint()