cleanup and rename

This commit is contained in:
jan 2018-03-28 10:54:15 -07:00
commit 1f332614f2
7 changed files with 153 additions and 216 deletions

View file

@ -0,0 +1,4 @@
from .split import split, clip
from .moments import get_volume, get_moments, number_of_moments
from .boundary import build_polyhedron, boundary_from_poly
from .shapes import build_tetrahedron, build_box, planes_from_tetrahedron, planes_from_box

View file

@ -4,6 +4,7 @@ from numpy.linalg import norm
from .util import _get_map, find_components, find_faces
try:
# Check if running with line_profiler
profile
except NameError:
def profile(f):

View file

@ -4,6 +4,7 @@ import numpy
from .util import find_faces
try:
# Check if running with line_profiler
profile
except NameError:
def profile(f):
@ -14,6 +15,10 @@ def number_of_moments(order):
return ((order + 1) * (order + 2) * (order + 3)) // 6
def get_volume(poly):
return get_moments(poly, 0)[0]
@profile
def get_moments(poly, poly_order):
vertices = poly['vertices']
@ -102,5 +107,3 @@ def get_moments(poly, poly_order):
prevlayer, curlayer = curlayer, prevlayer
return moments

View file

@ -43,7 +43,7 @@ def build_box(rbounds):
}
def planes_from_box(rbounds):
def planes_from_box(rbounds: numpy.ndarray):
faces = [
(( 0, 0, 1), -rbounds[0, 2]),
(( 0, 0, -1), rbounds[1, 2]),
@ -74,9 +74,3 @@ def planes_from_tetrahedron(vertices: numpy.ndarray):
return [plane for plane in zip(n, d)]
def volume_of_tetrahedron(vertices):
ad, bd, cd = vertices[0:3] - vertices[3]
return -ad @ numpy.cross(bd, cd) / 6

View file

@ -4,6 +4,7 @@ import numpy
from .util import _searchsorted_rows, _argsort_rows
try:
# Check if running with line_profiler
profile
except NameError:
def profile(f):

View file

@ -1,6 +1,7 @@
import numpy
try:
# Check if running with line_profiler
profile
except NameError:
def profile(f):

View file

@ -4,6 +4,7 @@ from .split import split
from .moments import get_moments, number_of_moments
try:
# Check if running with line_profiler
profile
except NameError:
def profile(f):