position_engine
PositionEngine
PositionEngine(balance_engine: BalanceEngine)
Bases: Observer, Notifier
PositionEngine computes point positions, distances, and coordinates.
Observes a BalanceEngine and updates its internal geometry state
whenever the balance engine notifies observers. It is also a
Notifier itself, so downstream observers (e.g. a
PlotEngine) are automatically
notified after every update.
Users can work with a PositionEngine directly — without any Plotly
dependency — to obtain span points, support positions, obstacle
coordinates, and point-to-cable distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BalanceEngine
|
|
required |
Examples:
1 2 3 4 5 6 | |
Source code in src/mechaphlowers/core/geometry/position_engine.py
54 55 56 57 58 59 60 | |
beta
property
beta: ndarray
Load angle (\(\beta\)) for each span, in radians.
add_obstacle
add_obstacle(
name: str,
span_index: int,
coords: ndarray,
object_type: str = 'ground',
support_reference: Literal['left', 'right'] = 'left',
span_length: ndarray | None = None,
)
Delegate to ObstacleArray.add_obstacle.
Source code in src/mechaphlowers/core/geometry/position_engine.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
add_obstacle_array
add_obstacle_array(obstacle_array: ObstacleArray) -> None
Attach an ObstacleArray for coordinate computation.
Source code in src/mechaphlowers/core/geometry/position_engine.py
112 113 114 115 116 | |
delete_obstacle
Delegate to ObstacleArray.delete_obstacle.
Source code in src/mechaphlowers/core/geometry/position_engine.py
139 140 141 142 | |
delete_point
Delegate to ObstacleArray.delete_point.
Source code in src/mechaphlowers/core/geometry/position_engine.py
144 145 146 147 | |
get_distances_from_obstacles
get_distances_from_obstacles() -> (
dict[str, dict[int, DistanceResult]]
)
Compute distances for all obstacles to their respective spans.
Only in absolute coordiantes.
{ 'obs_0': {0: DistanceResult, 1: DistanceResult}, 'obs_1': {0: DistanceResult} }
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, dict[int, DistanceResult]]
|
dictionary of DistanceResult, sorted by obstacles |
Source code in src/mechaphlowers/core/geometry/position_engine.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
get_insulators_points
get_insulators_points() -> ndarray
Return insulator attachment points (absolute section frame).
Source code in src/mechaphlowers/core/geometry/position_engine.py
175 176 177 | |
get_loads_coords
get_loads_coords(
project: bool = False, frame_index: int = 0
) -> dict
Return a dictionary of load coordinates indexed by span.
If loads exist on spans 0 and 2, the result looks like:
{0: [x0, y0, z0], 2: [x2, y2, z2]}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
|
False
|
|
int
|
Index of the support frame used for projection.
Must be in |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
Dict mapping span index ( |
dict
|
|
Source code in src/mechaphlowers/core/geometry/position_engine.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
get_loads_coords_group_points
get_loads_coords_group_points(
project: bool = False, frame_index: int = 0
) -> dict
Same as get_loads_coords() but uses GroupPoints object
Return a dictionary of load coordinates indexed by span.
If loads exist on spans 0 and 2, the result looks like:
{0: [x0, y0, z0], 2: [x2, y2, z2]}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
|
False
|
|
int
|
Index of the support frame used for projection.
Must be in |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
Dict mapping span index ( |
dict
|
|
Source code in src/mechaphlowers/core/geometry/position_engine.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
get_obstacles_points
get_obstacles_points() -> ndarray
Return obstacle coordinates transformed to the section frame.
Source code in src/mechaphlowers/core/geometry/position_engine.py
179 180 181 | |
get_points_for_plot
Return Points objects for spans, supports, and insulators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
|
False
|
|
int
|
Index of the support frame for projection. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[Points, Points, Points]
|
Tuple of |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/mechaphlowers/core/geometry/position_engine.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
get_spans_points
Return span cable points in the requested coordinate frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Literal['section', 'localsection', 'cable']
|
One of |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy array of shape |
Source code in src/mechaphlowers/core/geometry/position_engine.py
158 159 160 161 162 163 164 165 166 167 168 169 | |
get_supports_points
get_supports_points() -> ndarray
Return support structure points (absolute section frame).
Source code in src/mechaphlowers/core/geometry/position_engine.py
171 172 173 | |
initialize_engine
initialize_engine(balance_engine: BalanceEngine) -> None
Initialise internal references from balance_engine.
Source code in src/mechaphlowers/core/geometry/position_engine.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |
obstacles_dict
obstacles_dict(project=False, frame_index=0) -> dict
Return obstacle coordinates keyed by obstacle name.
Format: {'obs_0': [[x0, y0, z0], [x1, y1, z1], ...]}.
Source code in src/mechaphlowers/core/geometry/position_engine.py
183 184 185 186 187 188 | |
point_distance
point_distance(
span_index: int, point: ndarray
) -> DistanceResult
Compute the minimum distance from point to a cable span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Span index in |
required |
|
ndarray
|
Absolute coordinates of shape |
required |
Returns:
| Type | Description |
|---|---|
DistanceResult
|
|
Raises:
| Type | Description |
|---|---|
IndexError
|
If |
ValueError
|
If |
Source code in src/mechaphlowers/core/geometry/position_engine.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
point_relative_to_absolute
point_relative_to_absolute(
span_index: int, point_relative: ndarray
) -> ndarray
Convert a point from the span-local frame to absolute coordinates.
Span-local frame definition:
- X: along the span direction projected onto the XY plane
- Y: perpendicular to X in the XY plane
- Z: vertical (global Z)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int
|
Span index in |
required |
|
ndarray
|
Coordinate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Absolute coordinate array of shape |
Raises:
| Type | Description |
|---|---|
IndexError
|
If |
ValueError
|
If |
Source code in src/mechaphlowers/core/geometry/position_engine.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
reset
reset(balance_engine: BalanceEngine) -> None
Reset geometry state from balance_engine.
Called automatically by update when the balance engine
notifies; can also be called manually after direct modifications to
the section array.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/mechaphlowers/core/geometry/position_engine.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
update
update(notifier: Notifier) -> None
Observer callback — invoked by BalanceEngine on state change.
Source code in src/mechaphlowers/core/geometry/position_engine.py
102 103 104 105 106 107 108 | |