cuboid
Bases: geometric_space
Represents a cuboid geometry in a 3D space.
This class defines a cuboid centered at a specific coordinate in a 3D space with configurable dimensions for height, width, and depth, along with packing strategies.
Attributes:
Name | Type | Description |
---|---|---|
p_h |
int
|
Number of units extending upward from the center along the height. |
p_w |
int
|
Number of units extending sideways from the center along the width. |
p_d |
int
|
Number of units extending backward from the center along the depth. |
p_h_prime |
int
|
Number of units extending downward from the center along the height. |
p_w_prime |
int
|
Number of units extending the opposite direction along the width. |
p_d_prime |
int
|
Number of units extending forward from the center along the depth. |
center |
coordinate_3d
|
The center coordinate of the cuboid. |
name |
str
|
The name of the cuboid geometry. |
Source code in tinybig/koala/geometry/cuboid.py
14 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
__init__(p_h, p_w, p_d=0, p_h_prime=None, p_w_prime=None, p_d_prime=None, center=coordinate_3d(0, 0, 0), name='cuboid_geometry', *args, **kwargs)
Initializes the cuboid geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_h
|
int
|
Number of units extending upward from the center along the height. |
required |
p_w
|
int
|
Number of units extending sideways from the center along the width. |
required |
p_d
|
int
|
Number of units extending backward from the center along the depth (default is 0). |
0
|
p_h_prime
|
int
|
Number of units extending downward from the center along the height (default is equal to |
None
|
p_w_prime
|
int
|
Number of units extending the opposite direction along the width (default is equal to |
None
|
p_d_prime
|
int
|
Number of units extending forward from the center along the depth (default is equal to |
None
|
center
|
coordinate_3d
|
The center coordinate of the cuboid (default is coordinate_3d(0, 0, 0)). |
coordinate_3d(0, 0, 0)
|
name
|
str
|
The name of the cuboid geometry (default is 'cuboid_geometry'). |
'cuboid_geometry'
|
*args
|
Additional arguments for customization. |
()
|
|
**kwargs
|
Additional arguments for customization. |
()
|
Source code in tinybig/koala/geometry/cuboid.py
depth()
Calculates the depth of the cuboid.
Returns:
Type | Description |
---|---|
int
|
The depth of the cuboid. |
generate_coordinates(*args, **kwargs)
Generates the coordinates of all points within the cuboid.
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 cuboid and values are indicators (default is 1). |
Source code in tinybig/koala/geometry/cuboid.py
get_packing_strategies()
staticmethod
Returns the available packing strategies for the cuboid.
Returns:
Type | Description |
---|---|
list
|
A list of packing strategies: ['sparse_square', 'complete_square', 'dense_square', 'densest_packing']. |
Source code in tinybig/koala/geometry/cuboid.py
height()
Calculates the height of the cuboid.
Returns:
Type | Description |
---|---|
int
|
The height of the cuboid. |
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_square': Centers are 3 times the dimensions apart. - 'complete_square': Centers are 2 times the dimensions apart. - 'dense_square': Centers are 1 time the dimensions 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. |
Source code in tinybig/koala/geometry/cuboid.py
shape()
Returns the dimensions of the cuboid as a tuple.
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing the height, width, and depth of the cuboid. |
width()
Calculates the width of the cuboid.
Returns:
Type | Description |
---|---|
int
|
The width of the cuboid. |