Exemplo n.º 1
0
"""Customizing Axes.
Cartesian planes can be displaced
from their lower-range default position"""
from vedo import Sphere, Axes, precision, show

sph = Sphere().scale([4, 3, 2]).shift(5, 6, 7).c('green2', 0.1)

axs = Axes(
    sph,  # build axes for object sph
    xtitle="x axis",
    ytitle="y axis",
    ztitle="z axis",
    htitle='An ellipsoid at ' + precision(sph.centerOfMass(), 2),
    hTitleFont=1,
    hTitleColor='red3',
    zxGrid=True,
    xyFrameLine=2,
    yzFrameLine=2,
    zxFrameLine=2,
    xyFrameColor='red3',
    yzFrameColor='green3',
    zxFrameColor='blue3',
    xyShift=0.2,  # move xy plane 20% along z
    yzShift=0.2,  # move yz plane 20% along x
    zxShift=0.2,  # move zx plane 20% along y
)

show(sph, axs, __doc__)
Exemplo n.º 2
0
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),
                   [0.19883616, 0.48003298, 0.85441941])


###################################### findCellsWithin
Exemplo n.º 3
0
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

######################################transformMesh