sphere
Bases: geometric_space
Represents a spherical geometry in a 3D space.
This class defines a sphere centered at a specific coordinate in a 3D space with configurable radius and packing strategies.
Attributes:
Name | Type | Description |
---|---|---|
p_r |
int
|
Radius of the sphere. |
center |
coordinate_3d
|
The center coordinate of the sphere. |
name |
str
|
The name of the spherical geometry. |
Source code in tinybig/koala/geometry/sphere.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
__init__(p_r, center=coordinate_3d(0, 0, 0), name='sphere_geometry', *args, **kwargs)
Initializes the spherical geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_r
|
int
|
Radius of the sphere. |
required |
center
|
coordinate_3d
|
The center coordinate of the sphere (default is coordinate_3d(0, 0, 0)). |
coordinate_3d(0, 0, 0)
|
name
|
str
|
The name of the spherical geometry (default is 'sphere_geometry'). |
'sphere_geometry'
|
*args
|
Additional arguments for customization. |
()
|
|
**kwargs
|
Additional arguments for customization. |
()
|
Source code in tinybig/koala/geometry/sphere.py
generate_coordinates(*args, **kwargs)
Generates the coordinates of all points within the sphere.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Additional arguments for customization. |
()
|
|
**kwargs
|
Additional arguments for customization. |
()
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary where keys are coordinates within the sphere and values are indicators (default is 1). |
Notes
This method uses the equation of a sphere: x^2 + y^2 + z^2 <= r^2 to determine valid coordinates within the sphere.
Source code in tinybig/koala/geometry/sphere.py
get_packing_strategies()
staticmethod
Returns the available packing strategies for the sphere.
Returns:
Type | Description |
---|---|
list
|
A list of packing strategies: ['sparse_simple_cubic', 'complete_simple_cubic', 'dense_simple_cubic', 'sparse_face_centered_cubic', 'complete_face_centered_cubic', 'dense_face_centered_cubic', 'sparse_hexagonal', 'complete_hexagonal', 'dense_hexagonal', 'densest_packing']. |
Source code in tinybig/koala/geometry/sphere.py
packing_strategy_parameters(packing_strategy='complete_square', *args, **kwargs)
Determines the center distances for packing based on the selected strategy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packing_strategy
|
str
|
The packing strategy to use (default is 'complete_square'). Options include: - 'sparse_simple_cubic': Centers are 2 times the radius apart. - 'complete_simple_cubic': Centers are 0.6667 * sqrt(3) times the radius apart. - 'dense_simple_cubic': Centers are equal to the radius apart. - 'sparse_face_centered_cubic': Centers are 2, sqrt(3), and 0.6667 * sqrt(6) times the radius apart. - 'complete_face_centered_cubic': Centers are sqrt(2), 0.6667 * sqrt(6), and 1.3333 times the radius apart. - 'dense_face_centered_cubic': Centers are equal to the radius apart. - 'sparse_hexagonal': Centers are 2 times the radius apart. - 'complete_hexagonal': Centers are 0.6667 * sqrt(3) times the radius apart. - 'dense_hexagonal': Centers are equal to the radius apart. - 'densest_packing': Centers are 1 unit apart. |
'complete_square'
|
*args
|
Additional arguments for customization. |
()
|
|
**kwargs
|
Additional arguments for customization. |
()
|
Returns:
Type | Description |
---|---|
tuple
|
A tuple (cd_h, cd_w, cd_d) representing the center distances for height, width, and depth. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unknown packing strategy is provided. |