Utilities
- mechanica.random_point(kind: int, dr: Optional[float] = None, phi0: Optional[float] = None, phi1: Optional[float] = None)
Get the coordinates of a random point in a kind of shape.
Currently supports
PointsType.Sphere,PointsType.Disk,PointsType.SolidCubeandPointsType.SolidSphere.- Parameters
kind – kind of shape
dr – thickness parameter; only applicable to solid sphere kind
phi0 – angle lower bound; only applicable to solid sphere kind
phi1 – angle upper bound; only applicable to solid sphere kind
- Returns
coordinates of random points
- Return type
- mechanica.random_points(kind: int, n: int = 1, dr: Optional[float] = None, phi0: Optional[float] = None, phi1: Optional[float] = None)
Get the coordinates of random points in a kind of shape.
Currently supports
PointsType.Sphere,PointsType.Disk,PointsType.SolidCubeandPointsType.SolidSphere.- Parameters
kind – kind of shape
n – number of points
dr – thickness parameter; only applicable to solid sphere kind
phi0 – angle lower bound; only applicable to solid sphere kind
phi1 – angle upper bound; only applicable to solid sphere kind
- Returns
coordinates of random points
- Return type
list of
MxVector3f
- mechanica.points(kind: int, n: int = 1)
Get the coordinates of uniform points in a kind of shape.
Currently supports
PointsType.RingandPointsType.Sphere.- Parameters
kind – kind of shape
n – number of points
- Returns
coordinates of uniform points
- Return type
list of
MxVector3f
- mechanica.filled_cube_uniform(corner1, corner2, num_parts_x: int = 2, num_parts_y: int = 2, num_parts_z: int = 2)
Get the coordinates of a uniformly filled cube.
- Parameters
corner1 (list of float or
MxVector3f) – first corner of cubecorner2 (list of float or
MxVector3f) – second corner of cubenum_parts_x – number of particles along x-direction of filling axes (>=2)
num_parts_y – number of particles along y-direction of filling axes (>=2)
num_parts_z – number of particles along z-direction of filling axes (>=2)
- Returns
coordinates of uniform points
- Return type
list of
MxVector3f
- mechanica.filled_cube_random(corner1, corner2, num_particles: int)
Get the coordinates of a randomly filled cube.
- Parameters
corner1 (list of float or
MxVector3f) – first corner of cubecorner2 (list of float or
MxVector3f) – second corner of cubenum_particles – number of particles
- Returns
coordinates of random points
- Return type
list of
MxVector3f
- mechanica.icosphere(subdivisions: int, phi0: float, phi1: float)
Get the coordinates of an icosphere.
- Parameters
subdivisions – number of subdivisions
phi0 – angle lower bound
phi1 – angle upper bound
- Returns
vertices and indices
- Return type
(list of
MxVector3f, list of int)
- mechanica.color3_names()
Get the names of all available colors
- Return type
list of str
- mechanica.primes(start_prime: int, n: int)
Get prime numbers, beginning with a starting prime number.
- Parameters
start_prime – Starting prime number
n – Number of prime numbers to get
- Returns
Requested prime numbers
- Return type
list of int
- mechanica.random_vector(mean: float, std: float) mechanica.mechanica.MxVector3f
Generates a randomly oriented vector with random magnitude with given mean and standard deviation according to a normal distribution.
- Parameters
mean (float) – magnitude mean
std (float) – magnitude standard deviation
- Return type
- Returns
MxVector3f
- mechanica.random_unit_vector() mechanica.mechanica.MxVector3f
Generates a randomly oriented unit vector.
- Return type
- Returns
MxVector3f
- mechanica.get_seed() unsigned int
Get the current seed for the pseudo-random number generator
- mechanica.set_seed(_seed: unsigned int const * = None) HRESULT
Set the current seed for the pseudo-random number generator
- Parameters
_seed (int) –
- Return type
int
- Returns
HRESULT