Cartesian Layout

Coordinate system that represents a Cartesian grid of signed coordinates.

Header: fiction/layouts/cartesian_layout.hpp

class cartesian_layout : public fiction::layouts::layout_base

A layout type that utilizes signed offset coordinates to represent a Cartesian grid. Its faces are organized in the following way:

+-------+-------+-------+-------+
|       |       |       |       |
| (0,0) | (1,0) | (2,0) | (3,0) |
|       |       |       |       |
+-------+-------+-------+-------+
|       |       |       |       |
| (0,1) | (1,1) | (2,1) | (3,1) |
|       |       |       |       |
+-------+-------+-------+-------+
|       |       |       |       |
| (0,2) | (1,2) | (2,2) | (3,2) |
|       |       |       |       |
+-------+-------+-------+-------+

Subclassed by fiction::layouts::cell_grid< magnet_type >, fiction::layouts::cell_grid< cell_type >, fiction::layouts::gate_layout< cartesian_layout >, fiction::layouts::gate_layout< fiction::layouts::cartesian_layout >, fiction::layouts::cell_grid< CellType >, fiction::layouts::gate_layout< CoordinateLayout >, fiction::physical_design::detail::wiring_reduction_layout

Public Types

using base_type = cartesian_layout

Geometry base type.

Public Functions

inline explicit cartesian_layout(const extent &size = {})

Creates geometry with half-open, zero-origin bounds. The default extent is empty.

Parameters:

size – Axis sizes.

Throws:
  • std::invalid_argument – If a size exceeds the coordinate domain.

  • std::out_of_range – If the layer count exceeds two.

inline cartesian_layout clone() const noexcept
Returns:

Independent copy of the geometry.

template<std::integral X, std::integral Y, std::integral Z = uint64_t>
inline constexpr coordinate coord(const X x, const Y y, const Z z = 0ul) const

Creates and returns a coordinate in the layout from the given x-, y-, and z-values.

Note

This function is equivalent to calling coordinate(x, y, z).

Template Parameters:
  • X – x-type.

  • Y – y-type.

  • Z – z-type.

Parameters:
  • x – x-value.

  • y – y-value.

  • z – z-value.

Throws:

std::overflow_error – If an axis is outside the signed 32-bit range.

Returns:

A coordinate in the layout of type coordinate.

inline uint32_t width() const noexcept
Returns:

Number of coordinates along x.

inline uint32_t height() const noexcept
Returns:

Number of coordinates along y.

inline uint32_t layers() const noexcept
Returns:

Number of layers.

inline extent get_extent() const noexcept
Returns:

Independent value of the layout extent.

inline uint64_t area() const noexcept
Returns:

Width times height.

inline void resize(const extent &size)

Changes the geometry’s axis sizes.

Parameters:

size – Axis sizes.

Throws:
  • std::invalid_argument – If a size exceeds the coordinate domain.

  • std::out_of_range – If the layer count exceeds two. The dimensions remain unchanged.

inline std::optional<coordinate> last_coordinate() const noexcept
Returns:

Last coordinate in iteration order, or no value for empty geometry.

inline std::optional<coordinate> north(const coordinate &c) const noexcept

Returns the north neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> north_east(const coordinate &c) const noexcept

Returns the north-east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> east(const coordinate &c) const noexcept

Returns the east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> south_east(const coordinate &c) const noexcept

Returns the south-east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> south(const coordinate &c) const noexcept

Returns the south neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> south_west(const coordinate &c) const noexcept

Returns the south-west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> west(const coordinate &c) const noexcept

Returns the west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> north_west(const coordinate &c) const noexcept

Returns the north-west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> above(const coordinate &c) const noexcept

Returns the above neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline std::optional<coordinate> below(const coordinate &c) const noexcept

Returns the below neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

inline constexpr bool is_north_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly north of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly north of c1.

inline constexpr bool is_east_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly east of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly east of c1.

inline constexpr bool is_south_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly south of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly south of c1.

inline constexpr bool is_west_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly west of c1.

inline bool is_adjacent_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is either directly north, east, south, or west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is either directly north, east, south, or west of c1.

inline bool is_adjacent_elevation_of(const coordinate &c1, const coordinate &c2) const noexcept

Similar to is_adjacent_of but also considers c1’s elevation, i.e., if c2 is adjacent to above(c1) or below(c1).

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is either directly north, east, south, or west of c1 or c1’s elevations.

inline constexpr bool is_above(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly above coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly above c1.

inline constexpr bool is_below(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is directly below coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly below c1.

inline constexpr bool is_northwards_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is somewhere north of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere north of c1.

inline constexpr bool is_eastwards_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is somewhere east of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere east of c1.

inline constexpr bool is_southwards_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is somewhere south of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere south of c1.

inline constexpr bool is_westwards_of(const coordinate &c1, const coordinate &c2) const noexcept

Returns true iff coordinate c2 is somewhere west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere west of c1.

inline bool is_at_northern_border(const coordinate &c) const noexcept

Returns whether the given coordinate is located at the layout’s northern border where y is minimal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s northern border.

inline bool is_at_eastern_border(const coordinate &c) const noexcept

Returns whether the given coordinate is located at the layout’s eastern border where x is maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s eastern border.

inline bool is_at_southern_border(const coordinate &c) const noexcept

Returns whether the given coordinate is located at the layout’s southern border where y is maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s southern border.

inline bool is_at_western_border(const coordinate &c) const noexcept

Returns whether the given coordinate is located at the layout’s western border where x is minimal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s western border.

inline bool is_at_any_border(const coordinate &c) const noexcept

Returns whether the given coordinate is located at any of the layout’s borders where x or y are either minimal or maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at any of the layout’s borders.

inline std::optional<coordinate> northern_border_of(const coordinate &c) const noexcept

Projects a coordinate to the northern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

inline std::optional<coordinate> eastern_border_of(const coordinate &c) const noexcept

Projects a coordinate to the eastern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

inline std::optional<coordinate> southern_border_of(const coordinate &c) const noexcept

Projects a coordinate to the southern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

inline std::optional<coordinate> western_border_of(const coordinate &c) const noexcept

Projects a coordinate to the western border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

inline constexpr bool is_ground_layer(const coordinate &c) const noexcept

Returns whether the given coordinate is located in the ground layer where z is minimal.

Parameters:

c – Coordinate to check for elevation.

Returns:

true iff c is in ground layer.

inline constexpr bool is_crossing_layer(const coordinate &c) const noexcept

Returns whether the given coordinate is located in the crossing layer at z = 1.

Parameters:

c – Coordinate to check for elevation.

Returns:

true iff c.z is 1.

inline bool contains_coordinate(const coordinate &c) const noexcept

Returns whether the given coordinate is located within the layout bounds.

Parameters:

c – Coordinate to check for boundary.

Returns:

true iff c is located within the layout bounds.

inline bool is_within_bounds(const coordinate &c) const noexcept

Tests whether the geometry contains a coordinate.

Parameters:

c – Coordinate.

Returns:

Whether the geometry contains the coordinate.

inline auto coordinates(const std::optional<coordinate> start = std::nullopt, const std::optional<coordinate> stop = std::nullopt) const

Returns a range of all coordinates accessible in the layout between start and stop. If no values are provided, all coordinates in the layout will be included. The returned iterator range points to the first and last coordinate, respectively. The range object can be used within a for-each loop. Incrementing the iterator is equivalent to nested for loops in the order z, y, x. Consequently, the iteration will happen inside out, i.e., x will be iterated first, then y, then z.

Parameters:
  • start – First coordinate to include in the range of all coordinates.

  • stop – Last coordinate (exclusive) to include in the range of all coordinates.

Returns:

An iterator range from start to stop. If they are not provided, the first/last coordinate is used as a default.

template<typename Fn>
inline void foreach_coordinate(Fn &&fn, const std::optional<coordinate> start = std::nullopt, const std::optional<coordinate> stop = std::nullopt) const

Applies a function to all coordinates accessible in the layout between start and stop. The iteration order is the same as for the coordinates function.

Template Parameters:

Fn – Functor type that has to comply with the restrictions imposed by mockturtle::foreach_element.

Parameters:
  • fn – Functor to apply to each coordinate in the range.

  • start – First coordinate to include in the range of all coordinates.

  • stop – Last coordinate (exclusive) to include in the range of all coordinates.

inline auto ground_coordinates(const std::optional<coordinate> start = std::nullopt, const std::optional<coordinate> stop = std::nullopt) const

Returns a range of all coordinates accessible in the layout’s ground layer between start and stop. The iteration order is the same as for the coordinates function but without the z axis.

Parameters:
  • start – First coordinate to include in the range of all ground coordinates.

  • stop – Last coordinate (exclusive) to include in the range of all ground coordinates.

Throws:

std::invalid_argument – If a range bound lies outside layer zero.

Returns:

An iterator range from start to stop. If they are not provided, the first/last coordinate in the ground layer is used as a default.

template<typename Fn>
inline void foreach_ground_coordinate(Fn &&fn, const std::optional<coordinate> start = std::nullopt, const std::optional<coordinate> stop = std::nullopt) const

Applies a function to all coordinates accessible in the layout’s ground layer between start and stop. The iteration order is the same as for the ground_coordinates function.

Template Parameters:

Fn – Functor type that has to comply with the restrictions imposed by mockturtle::foreach_element.

Parameters:
  • fn – Functor to apply to each coordinate in the range.

  • start – First coordinate to include in the range of all ground coordinates.

  • stop – Last coordinate (exclusive) to include in the range of all ground coordinates.

Throws:

std::invalid_argument – If a range bound lies outside layer zero.

inline auto adjacent_coordinates(const coordinate &c) const

Returns a container that contains all coordinates that are adjacent to a given one. Thereby, only cardinal directions are being considered, i.e., the container contains all coordinates ac for which is_adjacent(c, ac) returns true.

Coordinates that are outside of the layout bounds are not considered. Thereby, the size of the returned container is at most 4.

Parameters:

c – Coordinate whose adjacent ones are desired.

Returns:

A container that contains all of c’s adjacent coordinates.

template<typename Fn>
inline void foreach_adjacent_coordinate(const coordinate &c, Fn &&fn) const

Applies a function to all coordinates adjacent to a given one. Thereby, only cardinal directions are being considered, i.e., the function is applied to all coordinates ac for which is_adjacent(c, ac) returns true.

Coordinates that are outside of the layout bounds are not considered. Thereby, at most 4 coordinates are touched.

Template Parameters:

Fn – Functor type.

Parameters:
  • c – Coordinate whose adjacent ones are desired.

  • fn – Functor invoked as an lvalue for each of c’s adjacent coordinates.

inline auto adjacent_opposite_coordinates(const coordinate &c) const

Returns a container that contains all coordinates pairs of opposing adjacent coordinates with respect to a given one. In this Cartesian layout, the container will contain (north(c), south(c)) and (east(c), west(c)).

This function comes in handy when straight lines on the layout are to be examined.

Coordinates outside of the layout bounds are not being considered.

Parameters:

c – Coordinate whose opposite ones are desired.

Returns:

A container that contains pairs of c’s opposing coordinates.

template<typename Fn>
inline void foreach_adjacent_opposite_coordinates(const coordinate &c, Fn &&fn) const

Applies a function to all opposing coordinate pairs adjacent to a given one. In this Cartesian layout, the function will be applied to (north(c), south(c)) and (east(c), west(c)).

Template Parameters:

Fn – Functor type.

Parameters:
  • c – Coordinate whose opposite adjacent ones are desired.

  • fn – Functor invoked as an lvalue for each of c’s opposite adjacent coordinate pairs.

Public Static Attributes

static constexpr auto min_fanin_size = 0u

Minimum number of incoming neighbors.

static constexpr auto max_fanin_size = 3u

Maximum number of incoming neighbors.

class cartesian_layout
class cartesian_layout(extent: extent | tuple[int, int] | tuple[int, int, int])

A layout type that utilizes offset coordinates to represent a Cartesian grid. Its faces are organized in the following way:

+-------+-------+-------+-------+
|       |       |       |       |
| (0,0) | (1,0) | (2,0) | (3,0) |
|       |       |       |       |
+-------+-------+-------+-------+
|       |       |       |       |
| (0,1) | (1,1) | (2,1) | (3,1) |
|       |       |       |       |
+-------+-------+-------+-------+
|       |       |       |       |
| (0,2) | (1,2) | (2,2) | (3,2) |
|       |       |       |       |
+-------+-------+-------+-------+
above(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the above neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

adjacent_coordinates(c: coordinate | tuple[int, int] | tuple[int, int, int]) → list[coordinate]

Returns a container that contains all coordinates that are adjacent to a given one. Thereby, only cardinal directions are being considered, i.e., the container contains all coordinates ac for which is_adjacent(c, ac) returns true.

Coordinates that are outside of the layout bounds are not considered. Thereby, the size of the returned container is at most 4.

Parameters:

c – Coordinate whose adjacent ones are desired.

Returns:

A container that contains all of c’s adjacent coordinates.

adjacent_opposite_coordinates(c: coordinate | tuple[int, int] | tuple[int, int, int]) → list[tuple[coordinate, coordinate]]

Returns a container that contains all coordinates pairs of opposing adjacent coordinates with respect to a given one. In this Cartesian layout, the container will contain (north(c), south(c)) and (east(c), west(c)).

This function comes in handy when straight lines on the layout are to be examined.

Coordinates outside of the layout bounds are not being considered.

Parameters:

c – Coordinate whose opposite ones are desired.

Returns:

A container that contains pairs of c’s opposing coordinates.

area() → int
Returns:

Width times height.

below(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the below neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

contains_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Tests the half-open geometry bounds.

coord(x: int, y: int, z: int = 0) → coordinate

Creates and returns a coordinate in the layout from the given x-, y-, and z-values.

Parameters:
  • x – x-value.

  • y – y-value.

  • z – z-value.

Template Args:
  • X – x-type.

  • Y – y-type.

  • Z – z-type.

Returns:

A coordinate in the layout of type coordinate.

Raises:

OverflowError – If an axis is outside the signed 32-bit range.

Note

This function is equivalent to calling coordinate(x, y, z).

coordinates(start: coordinate | tuple[int, int] | tuple[int, int, int] | None = None, stop: coordinate | tuple[int, int] | tuple[int, int, int] | None = None) → list[coordinate]

Returns coordinates in z/y/x order from the inclusive start to the exclusive stop. None uses the frame boundary.

east(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

eastern_border_of(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Projects a coordinate to the eastern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

get_extent() → extent

Returns the layout extent.

ground_coordinates(start: coordinate | tuple[int, int] | tuple[int, int, int] | None = None, stop: coordinate | tuple[int, int] | tuple[int, int, int] | None = None) → list[coordinate]

Returns layer-zero coordinates from the inclusive start to the exclusive stop. None uses the frame boundary. Bounds outside layer zero raise ValueError.

height() → int

Returns the height count.

is_above(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly above coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly above c1.

is_adjacent_elevation_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Similar to is_adjacent_of but also considers c1’s elevation, i.e., if c2 is adjacent to above(c1) or below(c1).

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is either directly north, east, south, or west of c1 or c1’s elevations.

is_adjacent_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is either directly north, east, south, or west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is either directly north, east, south, or west of c1.

is_at_any_border(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located at any of the layout’s borders where x or y are either minimal or maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at any of the layout’s borders.

is_at_eastern_border(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located at the layout’s eastern border where x is maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s eastern border.

is_at_northern_border(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located at the layout’s northern border where y is minimal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s northern border.

is_at_southern_border(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located at the layout’s southern border where y is maximal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s southern border.

is_at_western_border(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located at the layout’s western border where x is minimal.

Parameters:

c – Coordinate to check for border location.

Returns:

true iff c is located at the layout’s western border.

is_below(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly below coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly below c1.

is_crossing_layer(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located in the crossing layer at z = 1.

Parameters:

c – Coordinate to check for elevation.

Returns:

true iff c.z is 1.

is_east_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly east of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly east of c1.

is_eastwards_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is somewhere east of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere east of c1.

is_ground_layer(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns whether the given coordinate is located in the ground layer where z is minimal.

Parameters:

c – Coordinate to check for elevation.

Returns:

true iff c is in ground layer.

is_north_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly north of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly north of c1.

is_northwards_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is somewhere north of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere north of c1.

is_south_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly south of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly south of c1.

is_southwards_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is somewhere south of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere south of c1.

is_west_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is directly west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is directly west of c1.

is_westwards_of(c1: coordinate | tuple[int, int] | tuple[int, int, int], c2: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Returns true iff coordinate c2 is somewhere west of coordinate c1.

Parameters:
  • c1 – Base coordinate.

  • c2 – Coordinate to test for its location in relation to c1.

Returns:

true iff c2 is somewhere west of c1.

is_within_bounds(c: coordinate | tuple[int, int] | tuple[int, int, int]) → bool

Tests whether the geometry contains a coordinate.

Parameters:

c – Coordinate.

Returns:

Whether the geometry contains the coordinate.

last_coordinate() → coordinate | None

Returns the last coordinate, or None for empty geometry.

layers() → int

Returns the layers count.

north(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the north neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

north_east(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the north-east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

north_west(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the north-west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

northern_border_of(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Projects a coordinate to the northern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

resize(extent: extent | tuple[int, int] | tuple[int, int, int]) → None

Changes the geometry’s axis sizes.

Parameters:

extent – Axis sizes.

Raises:
  • ValueError – If a size exceeds the coordinate domain.

  • IndexError – If the layer count exceeds two. The dimensions remain unchanged.

south(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the south neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

south_east(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the south-east neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

south_west(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the south-west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

southern_border_of(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Projects a coordinate to the southern border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

west(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Returns the west neighbor when both coordinates lie inside the geometry.

Parameters:

c – Base coordinate.

Returns:

Neighbor, or no value at a boundary or outside the geometry.

western_border_of(c: coordinate | tuple[int, int] | tuple[int, int, int]) → coordinate | None

Projects a coordinate to the western border.

Parameters:

c – Coordinate to project.

Returns:

Projection, or no value if the projection lies outside the geometry.

width() → int

Returns the width count.