예제 #1
0

###################################### bounds
ss = sphere.clone().scale([1,2,3])
print('bounds',ss.xbounds())
assert np.allclose(ss.xbounds(), [-1,1], atol=0.01)
print('bounds',ss.ybounds())
assert np.allclose(ss.ybounds(), [-2,2], atol=0.01)
print('bounds',ss.zbounds())
assert np.allclose(ss.zbounds(), [-3,3], atol=0.01)


###################################### averageSize
print('averageSize',sphere.averageSize())
assert 0.9 < sphere.averageSize() < 1.0
print('diagonalSize',sphere.diagonalSize())
assert 3.3 < sphere.diagonalSize() < 3.5
print('maxBoundSize',sphere.maxBoundSize())
assert 1.9 < sphere.maxBoundSize() < 2.1
print('centerOfMass',sphere.centerOfMass())
assert np.allclose(sphere.centerOfMass(), [0,0,0])
print('volume',sphere.volume())
assert 4.1 < sphere.volume() < 4.2
print('area',sphere.area())
assert 12.5 < sphere.area() < 12.6


###################################### closestPoint
pt = [12,34,52]
print('closestPoint',sphere.closestPoint(pt), [0.19883616, 0.48003298, 0.85441941])
assert np.allclose(sphere.closestPoint(pt),
예제 #2
0
파일: test_actors.py 프로젝트: trasse/vedo
###################################### quantize
print('Test quantize')
sq = sphere.clone().quantize(0.1)
assert sq.N() == 834

###################################### bounds
print('Test bounds')
ss = sphere.clone().scale([1, 2, 3])
assert np.allclose(ss.xbounds(), [-1, 1], atol=0.01)
assert np.allclose(ss.ybounds(), [-2, 2], atol=0.01)
assert np.allclose(ss.zbounds(), [-3, 3], atol=0.01)

###################################### averageSize
print('Test sizes et al')
assert 0.9 < sphere.averageSize() < 1.0
assert 3.3 < sphere.diagonalSize() < 3.5
assert 1.9 < sphere.maxBoundSize() < 2.1
assert np.allclose(sphere.centerOfMass(), [0, 0, 0])
assert 4.1 < sphere.volume() < 4.2
assert 12.5 < sphere.area() < 12.6

###################################### closestPoint
print('Test closestPoint')
pt = [12, 34, 52]
assert np.allclose(sphere.closestPoint(pt),
                   [0.19883616, 0.48003298, 0.85441941])

###################################### findCellsWithin
print('Test findCellsWithin')
ics = sphere.findCellsWithin(xbounds=(-0.5, 0.5))
assert len(ics) == 1404