points
CoordsCalculator
CoordsCalculator(
section_array: SectionArray,
span_model: ISpan,
cable_loads: CableLoads,
get_displacement: Callable[[], ndarray],
obstacle_array: ObstacleArray | None = None,
additional_points_array: ObstacleArray | None = None,
**_,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
SectionArray
|
section array |
required |
|
ISpan
|
The span model to use for the points generation. |
required |
|
CableLoads
|
cable loads, used for beta angle |
required |
|
Callable
|
function that returns an array of chain displacement. Usually, comes from BalanceModel.get_displacement() |
required |
Source code in src/mechaphlowers/core/geometry/points.py
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 | |
beta
property
beta: ndarray
Get the beta angles for the cable spans. Beta is the angle du to the load on the cable
get_insulators
get_insulators() -> Points
Get the insulators in the section frame.
Source code in src/mechaphlowers/core/geometry/points.py
589 590 591 592 593 594 595 | |
get_points_for_plot
Get Points objects for span, supports and insulators. Can be used for plotting 2D or 3D graphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
Set to True if 2d graph: this project all objects into a support frame. Defaults to False. |
False
|
|
int
|
Index of the frame the projection is made. Should be between 0 and nb_supports-1 included. Unused if project is set to False. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[Points, Points, Points]
|
tuple[Points, Points, Points]: Points for spans, supports and insulators respectively. |
Raises:
| Type | Description |
|---|---|
ValueError
|
frame_index is out of range |
Source code in src/mechaphlowers/core/geometry/points.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
get_sea_level_supports
get_sea_level_supports() -> Points
Get the supports in the section frame.
Source code in src/mechaphlowers/core/geometry/points.py
585 586 587 | |
get_spans
get_spans
Get the spans Points in the specified frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Literal['cable', 'localsection', 'section']
|
frame |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the frame is not one of 'cable', 'localsection', or 'section'. |
Returns:
| Name | Type | Description |
|---|---|---|
Points |
Points
|
Points object containing the spans in the specified frame. |
Source code in src/mechaphlowers/core/geometry/points.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
get_supports
get_supports() -> Points
Get the supports in the section frame.
Source code in src/mechaphlowers/core/geometry/points.py
576 577 578 579 580 581 582 583 | |
project_to_selected_frame
project_to_selected_frame(
points_array: list[PointsT], frame_index: int
) -> list[PointsT]
Project points object into a support frame.
Used for 2D plots that need to be projected in a specific frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[PointsT]
|
array of Points of SparsePoints objects |
required |
|
int
|
Index of the frame the projection is made. |
required |
Returns:
| Type | Description |
|---|---|
list[PointsT]
|
list[PointsT]: array of points object projected in local frame |
list[PointsT]
|
projected into the frame of support number |
Source code in src/mechaphlowers/core/geometry/points.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
refresh_additional_points
refresh_additional_points() -> None
Need to be called when any modification to additional_points_array occurs
Source code in src/mechaphlowers/core/geometry/points.py
434 435 436 437 438 439 440 441 | |
refresh_obstacles
refresh_obstacles() -> None
Need to be called when any modification to obstacle_array occurs
Source code in src/mechaphlowers/core/geometry/points.py
425 426 427 428 429 430 431 432 | |
refresh_sparse_points
refresh_sparse_points() -> None
Refresh coordinates for both obstacle_array and additional_points_array.
Source code in src/mechaphlowers/core/geometry/points.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
set_cable_coordinates
set_cable_coordinates(resolution: int) -> None
Set the span in the cable frame 2D coordinates based on the span model and resolution.
Source code in src/mechaphlowers/core/geometry/points.py
405 406 407 | |
span_in_cable_frame
span_in_cable_frame() -> tuple[ndarray, ndarray, ndarray]
Get spans as vectors in the cable frame.
Source code in src/mechaphlowers/core/geometry/points.py
509 510 511 512 513 514 515 516 517 518 519 520 | |
span_in_localsection_frame
span_in_localsection_frame() -> (
tuple[ndarray, ndarray, ndarray]
)
Get spans as vectors in the localsection frame.
Source code in src/mechaphlowers/core/geometry/points.py
522 523 524 525 526 527 528 529 530 | |
span_in_section_frame
span_in_section_frame() -> tuple[ndarray, ndarray, ndarray]
Get spans as vectors in the section frame.
Source code in src/mechaphlowers/core/geometry/points.py
532 533 534 535 536 537 538 539 540 541 542 543 544 | |
Points
Points(coords: ndarray)
This class handles a set of points in 3D space, represented as a 3D numpy array. The points are stored in a 3D array with shape (number of layers, number of points, 3), where the last dimension represents the x, y, and z coordinates of each point.
It provides methods to convert the coordinates to vectors, points, and to create a Points object from.
Do not use this class directly, use the factory methods from_vectors or from_coords.
Examples:
1 2 3 4 5 6 7 | |
Source code in src/mechaphlowers/core/geometry/points.py
95 96 97 98 99 100 | |
vectors
property
vectors: tuple[ndarray, ndarray, ndarray]
Convert the coordinates to vectors. Returns the x, y, z coordinates as separate 2D arrays.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray, np.ndarray]: Three 2D arrays representing the x, y, and z coordinates. |
Examples:
1 2 3 4 5 6 | |
flat_layer
flat_layer() -> ndarray
Convert the coordinates to a 2D array of points with a column dedicated to layer number for plotting or other uses as dataframe usage.
Not implemented yet
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A 2D array of shape (number of layers x number of points, 4) where each row is a point (num layer, x, y, z). |
Source code in src/mechaphlowers/core/geometry/points.py
157 158 159 160 161 162 163 164 165 | |
from_coords
classmethod
from_coords(coords: ndarray) -> Self
Create Points from separate x, y, and z coordinates. Args: coords (np.ndarray): A 3D array of shape (layers, n_points, 3) where each row is a point (x, y, z).
Returns:
| Name | Type | Description |
|---|---|---|
Points |
Self
|
An instance of the Points class containing the coordinates. |
Source code in src/mechaphlowers/core/geometry/points.py
195 196 197 198 199 200 201 202 203 204 | |
from_vectors
classmethod
Create Points from a vector of coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
Array of x-coordinates (N, L). |
required |
|
ndarray
|
Array of y-coordinates (N, L). |
required |
|
ndarray
|
Array of z-coordinates (N, L). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Points |
Self
|
An instance of the Points class containing the coordinates. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x, y, or z are not 2D arrays. |
Source code in src/mechaphlowers/core/geometry/points.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
points
points(stack=False) -> ndarray
Convert the coordinates to a 2D array of points for plotting or other uses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If True, stack NaN values to separate spans when plotting. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A 2D array of shape (number of points, 3) where each row is a point (x, y, z). |
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Source code in src/mechaphlowers/core/geometry/points.py
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 | |
SparsePoints
SparsePoints(
object_name: list,
point_index: ndarray,
span_index: ndarray,
x: ndarray,
y: ndarray,
z: ndarray,
object_type: list,
)
Class handle set of 3D points grouped by objects, but all objects do not have the same number of points.
Main use case is for managing obstacle points.
Source code in src/mechaphlowers/core/geometry/points.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
dict_coords
dict_coords() -> dict
Returns a dictionary storing object coordinates.
Key is object name, value is coordinates of object.
Format: {'obs_0': [[x0, y0, z0], [x1, y1, z1], ...]}
Source code in src/mechaphlowers/core/geometry/points.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
points
points(stack=False) -> ndarray
[[x0, y0, z0], # first obstacle [x1, y1, z1], [np.nan, np.nan, np.nan], # separator if stack=True [x0, y0, z0], # second obstacle [x1, y1, z1], [x2, y2, z2], [np.nan, np.nan, np.nan], # separator if stack=True ]
Source code in src/mechaphlowers/core/geometry/points.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
compute_new_frame
compute_new_frame(
points: PointsT,
translation_vector: ndarray,
angle_to_project: float64,
) -> PointsT
Change the frame of the given Points by applying a translation and a rotation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Points
|
points to transform |
required |
|
ndarray
|
translation vector to apply |
required |
|
float64
|
angle of the rotation in radians |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Points |
PointsT
|
new Points object in the new frame |
Source code in src/mechaphlowers/core/geometry/points.py
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
coords_to_points
coords_to_points(coords: ndarray) -> ndarray
Convert the support coordinates to a format suitable for plotting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
A 3D array of shape (layers, n_points, 3) where each row is a point (x, y, z). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A 2D array of shape (number of points, 3) where each row is a point (x, y, z). |
Source code in src/mechaphlowers/core/geometry/points.py
64 65 66 67 68 69 70 71 72 73 | |
stack_nan
stack_nan(coords: ndarray) -> ndarray
Stack NaN values to the coords array to ensure consistent shape when plot and separate layers in a 2D array.
Source code in src/mechaphlowers/core/geometry/points.py
35 36 37 38 39 40 | |
vectors_to_coords
Convert 3 vectors of coordinates into an array of points.
Takes 3 numpy arrays representing x, y, and z coordinates and combines them into a single array of 3D points. The input vector format is expected to be (N, L) where N is the number of points per layer and L is the number of layers. The output will be an array of shape (number of layers, number of points, 3) where each row represents a point in 3D space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
Array of x-coordinates (N, L) |
required |
|
ndarray
|
Array of y-coordinates (N, L) |
required |
|
ndarray
|
Array of z-coordinates (N, L) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of points with shape (L,N,3) where N is the length of input vectors |
Source code in src/mechaphlowers/core/geometry/points.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |