Skip to content

references

cable_to_beta_plane

cable_to_beta_plane(
    x: ndarray,
    z: ndarray,
    beta: ndarray,
    a_chain: ndarray,
    b_chain: ndarray,
) -> tuple[ndarray, ndarray, ndarray]

cable_to_beta_plane is a function that allows to rotate from cable 2D plan to span 3D frame with an angle beta

Parameters:

Name Type Description Default

x

ndarray

n x d array spans x coordinates

required

z

ndarray

n x d array spans z coordinates

required

beta

ndarray

n array angle rotation

required

Returns:

Name Type Description
x_span ndarray

Rotated x coordinates in the span 3D frame.

y_span ndarray

Rotated y coordinates in the span 3D frame.

z_span ndarray

Rotated z coordinates in the span 3D frame.

Source code in src/mechaphlowers/core/geometry/references.py
 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
def cable_to_beta_plane(
    x: np.ndarray,
    z: np.ndarray,
    beta: np.ndarray,
    a_chain: np.ndarray,
    b_chain: np.ndarray,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """cable_to_beta_plane is a function that allows to rotate from cable 2D plan to span 3D frame with an angle beta


    Args:
        x (np.ndarray): n x d array spans x coordinates
        z (np.ndarray): n x d array spans z coordinates
        beta (np.ndarray): n array angle rotation

    Returns:
            x_span: Rotated x coordinates in the span 3D frame.
            y_span: Rotated y coordinates in the span 3D frame.
            z_span: Rotated z coordinates in the span 3D frame.
    """

    # beta is inverted because these formulas come from the prototype, which has indirect angles
    beta_inverted = -beta

    alpha = np.arctan((b_chain * np.sin(beta_inverted)) / a_chain)

    projected_x_span = x * np.cos(alpha)
    projected_y_span = z * np.sin(beta_inverted) - x * np.cos(
        beta_inverted
    ) * np.sin(alpha)
    projected_z_span = z * np.cos(beta_inverted) + x * np.sin(
        beta_inverted
    ) * np.sin(alpha)

    return projected_x_span, projected_y_span, projected_z_span

cable_to_localsection_frame

cable_to_localsection_frame(
    x: ndarray,
    y: ndarray,
    z: ndarray,
    azimuth_angle: ndarray,
) -> tuple[ndarray, ndarray, ndarray]

cable_to_localsection_frame is a function that rotates the cable coordinates from the cable frame to the localsection frame The localsection frame is the the section frame with origin at the left support of the cable, but with the same axes than the section frame.

Parameters:

Name Type Description Default

x

ndarray

n x d array spans x coordinates

required

y

ndarray

n x d array spans y coordinates

required

z

ndarray

n x d array spans z coordinates

required

azimuth_angle

ndarray

absolute angle of the span (radians)

required

Returns:

Name Type Description
x_span ndarray

Rotated x coordinates in the localsection frame.

y_span ndarray

Rotated y coordinates in the localsection frame.

z_span ndarray

Rotated z coordinates in the localsection frame.

Source code in src/mechaphlowers/core/geometry/references.py
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
def cable_to_localsection_frame(
    x: np.ndarray, y: np.ndarray, z: np.ndarray, azimuth_angle: np.ndarray
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """cable_to_localsection_frame is a function that rotates the cable coordinates from the cable frame to the localsection frame
    The localsection frame is the the section frame with origin at the left support of the cable, but with the same axes than the section frame.

    Args:
        x (np.ndarray): n x d array spans x coordinates
        y (np.ndarray): n x d array spans y coordinates
        z (np.ndarray): n x d array spans z coordinates
        azimuth_angle (np.ndarray): absolute angle of the span (radians)

    Returns:
            x_span: Rotated x coordinates in the localsection frame.
            y_span: Rotated y coordinates in the localsection frame.
            z_span: Rotated z coordinates in the localsection frame.
    """

    # beta is inverted because these formulas come from the prototype, which has indirect angles
    azimuth_angle_inverted = -azimuth_angle

    projected_x_span = x * np.cos(azimuth_angle_inverted) - y * np.sin(
        azimuth_angle_inverted
    )
    projected_y_span = -x * np.sin(azimuth_angle_inverted) + y * np.cos(
        azimuth_angle_inverted
    )

    return projected_x_span, projected_y_span, z

translate_cable_to_support

translate_cable_to_support(
    x_span: ndarray,
    y_span: ndarray,
    z_span: ndarray,
    altitude: ndarray,
    span_length: ndarray,
    crossarm_length: ndarray,
    insulator_length: ndarray,
    line_angle: ndarray,
    displacement_vector: ndarray,
    ground_altitude: ndarray,
) -> tuple[ndarray, ndarray, ndarray]

Translate cable using altitude and span length

Parameters:

Name Type Description Default

x_span

ndarray

x coordinates rotated

required

y_span

ndarray

y coordinates rotated

required

z_span

ndarray

z coordinates rotated

required

altitude

ndarray

conductor heigth altitude

required

span_length

ndarray

span length

required

crossarm_length

ndarray

crossarm length

required

insulator_length

ndarray

insulator length

required

Returns:

Type Description
tuple[ndarray, ndarray, ndarray]

tuple[np.ndarray, np.ndarray, np.ndarray]: translated x_span, y_span and z_span

Source code in src/mechaphlowers/core/geometry/references.py
213
214
215
216
217
218
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
252
253
254
255
256
257
258
259
260
261
262
def translate_cable_to_support(
    x_span: np.ndarray,
    y_span: np.ndarray,
    z_span: np.ndarray,
    altitude: np.ndarray,
    span_length: np.ndarray,
    crossarm_length: np.ndarray,
    insulator_length: np.ndarray,
    line_angle: np.ndarray,
    displacement_vector: np.ndarray,
    ground_altitude: np.ndarray,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """Translate cable using altitude and span length

    Args:
        x_span (np.ndarray): x coordinates rotated
        y_span (np.ndarray): y coordinates rotated
        z_span (np.ndarray): z coordinates rotated
        altitude (np.ndarray): conductor heigth altitude
        span_length (np.ndarray): span length
        crossarm_length (np.ndarray): crossarm length
        insulator_length (np.ndarray): insulator length

    Returns:
        tuple[np.ndarray, np.ndarray, np.ndarray]: translated x_span, y_span and z_span
    """

    supports_ground_coords = get_supports_ground_coords(
        span_length=span_length,
        line_angle=line_angle,
        ground_altitude=ground_altitude,
    )

    _, edge_arm_coords = get_edge_arm_coords(
        supports_ground_coords=supports_ground_coords,
        conductor_attachment_altitude=altitude,
        crossarm_length=crossarm_length,
        line_angle=line_angle,
        insulator_length=insulator_length,
    )

    attachment_coords = get_attachment_coords(
        edge_arm_coords, displacement_vector
    )

    z_span += -z_span[0, :] + attachment_coords[:-1, 2]
    y_span += -y_span[0, :] + attachment_coords[:-1, 1]
    x_span += -x_span[0, :] + attachment_coords[:-1, 0]

    return x_span, y_span, z_span

translate_cable_to_support_from_attachments

translate_cable_to_support_from_attachments(
    x_span: ndarray,
    y_span: ndarray,
    z_span: ndarray,
    attachment_coords: ndarray,
) -> tuple[ndarray, ndarray, ndarray]

Translate cable using altitude and span length

Parameters:

Name Type Description Default

x_span

ndarray

x coordinates rotated

required

y_span

ndarray

y coordinates rotated

required

z_span

ndarray

z coordinates rotated

required

attachment_coords

ndarray

coordinates of the attachement of the cable

required

Returns:

Type Description
tuple[ndarray, ndarray, ndarray]

tuple[np.ndarray, np.ndarray, np.ndarray]: translated x_span, y_span and z_span

Source code in src/mechaphlowers/core/geometry/references.py
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
def translate_cable_to_support_from_attachments(
    x_span: np.ndarray,
    y_span: np.ndarray,
    z_span: np.ndarray,
    attachment_coords: np.ndarray,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """Translate cable using altitude and span length

    Args:
        x_span (np.ndarray): x coordinates rotated
        y_span (np.ndarray): y coordinates rotated
        z_span (np.ndarray): z coordinates rotated
        attachment_coords (np.ndarray): coordinates of the attachement of the cable

    Returns:
        tuple[np.ndarray, np.ndarray, np.ndarray]: translated x_span, y_span and z_span
    """

    z_span += -z_span[0, :] + attachment_coords[:-1, 2]
    y_span += -y_span[0, :] + attachment_coords[:-1, 1]
    x_span += -x_span[0, :] + attachment_coords[:-1, 0]

    return x_span, y_span, z_span

translate_to_absolute_frame

translate_to_absolute_frame(
    x: ndarray,
    y: ndarray,
    z: ndarray,
    translation_vector: ndarray,
) -> tuple[ndarray, ndarray, ndarray]

From local frame to absolute frame x/y/z are already rotated Used for obstacles

Source code in src/mechaphlowers/core/geometry/references.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
def translate_to_absolute_frame(
    x: np.ndarray,
    y: np.ndarray,
    z: np.ndarray,
    translation_vector: np.ndarray,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
    """From local frame to absolute frame
    x/y/z are already rotated
    Used for obstacles
    """

    x = x + translation_vector[:, 0]
    y = y + translation_vector[:, 1]

    return x, y, z

vectors_to_points

vectors_to_points(
    x: ndarray, y: ndarray, z: ndarray
) -> ndarray

vectors_to_points is a function that allows to stack x, y and z arrays into a single array

vectors are a n x d array where n is the number of points per span and d is the number of spans points are a n x 3 array where n is the number of points per span and 3 is the number of coordinates

Parameters:

Name Type Description Default

x

ndarray

n x d array spans x coordinates

required

y

ndarray

n x d array spans y coordinates

required

z

ndarray

n x d array spans z coordinates

required

Returns:

Type Description
ndarray

np.ndarray: 3 x n array vector coordinates

Source code in src/mechaphlowers/core/geometry/references.py
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
def vectors_to_points(
    x: np.ndarray, y: np.ndarray, z: np.ndarray
) -> np.ndarray:
    """vectors_to_points is a function that allows to stack x, y and z arrays into a single array

    vectors are a n x d array where n is the number of points per span and d is the number of spans
    points are a n x 3 array where n is the number of points per span and 3 is the number of coordinates

    Args:
        x (np.ndarray): n x d array spans x coordinates
        y (np.ndarray): n x d array spans y coordinates
        z (np.ndarray): n x d array spans z coordinates

    Returns:
        np.ndarray: 3 x n array vector coordinates
    """

    cc = np.vstack(
        [
            x.reshape(-1, order='F'),
            y.reshape(-1, order='F'),
            z.reshape(-1, order='F'),
        ]
    ).T
    return cc