bluemira.builders._varied_offset

Module containing functions to generate variable offset curves

Functions

varied_offset(→ bluemira.geometry.wire.BluemiraWire)

Create a new wire that offsets the given wire using a variable

_throw_if_inputs_invalid(wire, inboard_offset_degree, ...)

_sort_coords_by_angle(...)

Sort the given angles and use that to re-order the coords.

_calculate_offset_magnitudes(...)

_calculate_variable_offset_magnitudes(...)

Calculate the variable offset magnitude for each of the given angles.

_calculate_normals_2d(...)

Calculate the unit normals to the tangents at each of the given

_2d_coords_to_wire(→ bluemira.geometry.wire.BluemiraWire)

Build a wire from a 2D array of coordinates using a bspline.

Module Contents

bluemira.builders._varied_offset.varied_offset(wire: bluemira.geometry.wire.BluemiraWire, inboard_offset: float, outboard_offset: float, inboard_offset_degree: float, outboard_offset_degree: float, num_points: int = 200) bluemira.geometry.wire.BluemiraWire

Create a new wire that offsets the given wire using a variable offset in the xz plane.

All angles are measured from the negative x-direction (9 o’clock), centred at the center of mass of the wire. The offset will be ‘inboard_offset’ between the negative x-direction and ‘inboard_offset_degree’. Between ‘outboard_offset_degree’ and the positive x-direction the offset will be ‘outboard_offset’. Between those angles, the offset will linearly transition between the min and max.

Parameters:
  • wire (bluemira.geometry.wire.BluemiraWire) – The wire to create the offset from. This should be convex in order to get a sensible, non-intersecting, offset.

  • inboard_offset (float) – The size of the offset on the inboard side.

  • outboard_offset (float) – The size of the offset on the outboard side.

  • inboard_offset_degree (float) – The angle at which the variable offset should begin, in degrees.

  • outboard_offset_degree (float) – The angle at which the variable offset should end, in degrees.

  • num_points (int) – The number of points to use in the discretisation of the input wire.

Returns:

New wire at a variable offset to the input.

Raises:

GeometryError – Wire must be planar

Return type:

bluemira.geometry.wire.BluemiraWire

bluemira.builders._varied_offset._throw_if_inputs_invalid(wire: bluemira.geometry.wire.BluemiraWire, inboard_offset_degree: float, outboard_offset_degree: float)
Parameters:
bluemira.builders._varied_offset._sort_coords_by_angle(angles: numpy.typing.NDArray[numpy.float64], coords: numpy.typing.NDArray[numpy.float64]) tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]]

Sort the given angles and use that to re-order the coords.

Returns:

  • the sorted angles

  • the coordinates associated with the sorted angles

Parameters:
  • angles (numpy.typing.NDArray[numpy.float64])

  • coords (numpy.typing.NDArray[numpy.float64])

Return type:

tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]]

bluemira.builders._varied_offset._calculate_offset_magnitudes(angles: numpy.typing.NDArray[numpy.float64], inboard_offset_degree: float, outboard_offset_degree: float, inboard_offset: float, outboard_offset: float) numpy.typing.NDArray[numpy.float64]
Returns:

The magnitude of the offset at each angle.

Parameters:
  • angles (numpy.typing.NDArray[numpy.float64])

  • inboard_offset_degree (float)

  • outboard_offset_degree (float)

  • inboard_offset (float)

  • outboard_offset (float)

Return type:

numpy.typing.NDArray[numpy.float64]

bluemira.builders._varied_offset._calculate_variable_offset_magnitudes(angles: numpy.typing.NDArray[numpy.float64], start_angle: float, end_angle: float, inboard_offset: float, outboard_offset: float) numpy.typing.NDArray[numpy.float64]

Calculate the variable offset magnitude for each of the given angles.

The offset increases linearly between start_angle and end_angle, between inboard_offset and outboard_offset.

Returns:

Variable offset angles

Parameters:
  • angles (numpy.typing.NDArray[numpy.float64])

  • start_angle (float)

  • end_angle (float)

  • inboard_offset (float)

  • outboard_offset (float)

Return type:

numpy.typing.NDArray[numpy.float64]

bluemira.builders._varied_offset._calculate_normals_2d(wire_coords: numpy.typing.NDArray[numpy.float64]) numpy.typing.NDArray[numpy.float64]

Calculate the unit normals to the tangents at each of the given coordinates.

Returns:

2D normals

Parameters:

wire_coords (numpy.typing.NDArray[numpy.float64])

Return type:

numpy.typing.NDArray[numpy.float64]

Notes

That this applies an anti-clockwise rotation to the tangents, so to get an outward facing normal to a polygon, the coordinates should be ordered in the clockwise direction.

bluemira.builders._varied_offset._2d_coords_to_wire(coords_2d: numpy.typing.NDArray[numpy.float64]) bluemira.geometry.wire.BluemiraWire

Build a wire from a 2D array of coordinates using a bspline.

Returns:

the wire

Parameters:

coords_2d (numpy.typing.NDArray[numpy.float64])

Return type:

bluemira.geometry.wire.BluemiraWire