Exemplo n.º 1
0
def transform(object, transformation):
	object.coordinates = [
		(x, y, z) for [x, y, z, _] in [
			normalize(coordinate) @ transformation
			for coordinate in object.coordinates
		]
	]
	__project__("transformation")
Exemplo n.º 2
0
    def move(self, measure, direction):
        [dx, dy, dz, _] = normalize(direction) @ rotate(self.angle)

        self.origin = (self.x + measure * dx, self.y + measure * dy,
                       self.z + measure * dz)

        __log__(landscape=str(self))
        __project__("landscape")
Exemplo n.º 3
0
    def transform(self, coordinate):
        (cx, cy, cz) = self.perspective_center

        [x, y, z, w] = normalize(coordinate) \
            @ translate(-cx, -cy, -cz) \
            @ perspective(self.distance, coordinate[2]-cz) \
            @ translate(cx, cy, cz)

        return (x, y, z)
Exemplo n.º 4
0
	def move(self, id, measure, direction, reference):
		object = domain.get(id)

		if not reference:
			(dx, dy, _) = direction
		else:
			[dx, dy, *_] = normalize(direction) @ rotate(reference)

		transform(object, translate(measure * dx, measure * dy, 0))
Exemplo n.º 5
0
    def clip(self, line):
        [(i, origin)] = [(i, coordinate) for (i, coordinate) in enumerate(line)
                         if self.define_forwardty(coordinate)]
        other = line[i - 1]

        [x, y, z,
         _] = normalize(origin) @ (direction([origin, other], self.limit))

        return [origin, (x, y, z)]
Exemplo n.º 6
0
	def transform(self, coordinate, **kwargs):
		(cx, cy, cz) = self.center

		[x, y, z, _] = normalize(coordinate) \
					@ translate(-cx, -cy, 0) \
					@ scale(self.scale) \
					@ rotate(-self.angle) \
					@ translate(cx, cy, 0)

		return (x, y, z)