packagize

This commit is contained in:
jan 2018-03-20 16:57:11 -07:00
commit 002e7963c9

View file

@ -1,31 +0,0 @@
import numpy
from numpy import sin, cos
def rotate(poly, theta: float, axis: int):
s, c = sin(theta), cos(theta)
v0 = poly['vertices'][:, axis - 2].copy()
v1 = poly['vertices'][:, axis - 1].copy()
poly['vertices'][:, axis - 2] = c * v0 - s * v1
poly['vertices'][:, axis - 1] = s * v1 + c * v0
def translate(poly, shift):
poly['vertices'] += shift
def scale(poly, factor):
poly['vertices'] *= factor
def shear(poly, factor: float, axb: int, axs: int):
poly['vertices'][:, axb] += factor * poly['vertices'][:, axs]
def affine(poly, mat):
mat4x3 = mat[:, :3]
mat4x1 = mat[:, 3]
vh = mat4x3 @ poly['vertices'].T + mat4x1
poly['vertices'] = vh[:3, :] / vh[3, :]