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
58 59 60 61 62 63 64 | |
beta
property
beta: ndarray
Load angle (\(\beta\)) for each span, in radians.
add_additional_point
add_additional_point(
name: str,
span_index: int,
coords: ndarray,
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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
add_additional_points_array
add_additional_points_array(
additional_points_array: ObstacleArray,
) -> None
Attach an ObstacleArray for additional points coordinate computation.
Source code in src/mechaphlowers/core/geometry/position_engine.py
155 156 157 158 159 160 161 162 163 | |
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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
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
118 119 120 121 122 | |
delete_additional_point
Delegate to ObstacleArray.delete_obstacle.
Source code in src/mechaphlowers/core/geometry/position_engine.py
184 185 186 187 188 189 | |
delete_additional_point_by_index
Delegate to ObstacleArray.delete_point.
Source code in src/mechaphlowers/core/geometry/position_engine.py
191 192 193 194 195 196 | |
delete_obstacle
Delegate to ObstacleArray.delete_obstacle.
Source code in src/mechaphlowers/core/geometry/position_engine.py
145 146 147 148 | |
delete_point
Delegate to ObstacleArray.delete_point.
Source code in src/mechaphlowers/core/geometry/position_engine.py
150 151 152 153 | |
get_additional_points
get_additional_points() -> ndarray
Return additional points coordinates transformed to the section frame.
Source code in src/mechaphlowers/core/geometry/position_engine.py
232 233 234 235 236 237 238 | |
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
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
get_insulators_points
get_insulators_points() -> ndarray
Return insulator attachment points (absolute section frame).
Source code in src/mechaphlowers/core/geometry/position_engine.py
224 225 226 | |
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
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
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
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 | |
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
228 229 230 | |
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
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
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
207 208 209 210 211 212 213 214 215 216 217 218 | |
get_supports_points
get_supports_points() -> ndarray
Return support structure points (absolute section frame).
Source code in src/mechaphlowers/core/geometry/position_engine.py
220 221 222 | |
initialize_engine
initialize_engine(balance_engine: BalanceEngine) -> None
Initialise internal references from balance_engine.
Source code in src/mechaphlowers/core/geometry/position_engine.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
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
240 241 242 243 244 245 | |
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
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
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
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
update
update(notifier: Notifier) -> None
Observer callback — invoked by BalanceEngine on state change.
Source code in src/mechaphlowers/core/geometry/position_engine.py
108 109 110 111 112 113 114 | |