Geometry#

class sectionproperties.pre.geometry.Geometry(geom: Polygon, material: Material = Material(name='default', elastic_modulus=1, poissons_ratio=0, yield_strength=1, density=1, color='w'), control_points: Point | tuple[float, float] | None = None, tol: int = 12)[source]#

Bases: object

Class for defining the geometry of a contiguous section of a single material.

Provides an interface for the user to specify the geometry defining a section. A method is provided for generating a triangular mesh, transforming the section (e.g. translation, rotation, perimeter offset, mirroring), aligning the geometry to another geometry, and designating stress recovery points.

Methods

align_center

Aligns the geometry to a center point.

align_to

Aligns the geometry to another Geometry object.

assign_control_point

Assigns a control point to the geometry.

calculate_area

Calculates the area of the geometry.

calculate_centroid

Calculates the centroid of the geometry.

calculate_extents

Calculate geometry extents.

calculate_perimeter

Calculates the exterior perimeter of the geometry.

compile_geometry

Alias for create_facets_and_control_points().

create_facets_and_control_points

Creates geometry data from shapely data.

create_mesh

Creates a quadratic triangular mesh from the Geometry object.

from_3dm

Creates a Geometry object from a Rhino .3dm file.

from_dxf

An interface for the creation of Geometry objects from CAD .dxf files.

from_points

Creates Geometry from points, facets, a control point and holes.

from_rhino_encoding

Load an encoded single surface planer brep.

mirror_section

Mirrors the geometry about a point on either the x or y-axis.

offset_perimeter

Dilates or erodes the section perimeter by a discrete amount.

plot_geometry

Plots the geometry defined by the input section.

rotate_section

Rotate the Geometry object.

shift_points

Shifts the points in the geometry.

shift_section

Returns a new Geometry object translated by (x_offset, y_offset).

split_section

Splits geometry about a line.

Attributes

recovery_points

Returns the recovery points.

__init__(geom: Polygon, material: Material = Material(name='default', elastic_modulus=1, poissons_ratio=0, yield_strength=1, density=1, color='w'), control_points: Point | tuple[float, float] | None = None, tol: int = 12) None[source]#

Inits the Geometry class.

Parameters:
  • geom (Polygon) – A Shapely Polygon object that defines the geometry

  • material (Material) – A material to associate with this geometry

  • control_points (Point | tuple[float, float] | None) – An (x, y) coordinate within the geometry that represents a pre-assigned control point (aka, a region identification point) to be used instead of the automatically assigned control point generated with shapely.Polygon.representative_point().

  • tol (int) – Number of decimal places to round the geometry vertices to. A lower value may reduce accuracy of geometry but increases precision when aligning geometries to each other.

Raises:

ValueError – If geom is not valid, i.e. not a shapely object, or a MultiPolygon object

assign_control_point(control_point: tuple[float, float]) Geometry[source]#

Assigns a control point to the geometry.

Returns a new Geometry object with control_point assigned as the control point for the new Geometry. The assignment of a control point is intended to replace the control point automatically generated by shapely.Polygon.representative_point().

An assigned control point is carried through and transformed with the Geometry whenever it is shifted, aligned, mirrored, unioned, and/or rotated. If a perimeter_offset operation is applied, a check is performed to see if the assigned control point is still valid (within the new region) and, if so, it is kept. If not, a new control point is auto-generated.

The same check is performed when the geometry undergoes a difference operation (with the - operator) or a shift_points operation. If the assigned control point is valid, it is kept. If not, a new one is auto-generated.

For all other operations (e.g. symmetric difference, intersection, split), the assigned control point is discarded and a new one auto-generated.

Parameters:

control_point (tuple[float, float]) – An (x, y) coordinate that describes the distinct, contiguous, region of a single material within the geometry.

Returns:

New Geometry object with control_point assigned as the control point

Return type:

Geometry

static from_points(points: list[tuple[float, float]], facets: list[tuple[int, int]], control_points: list[tuple[float, float]], holes: list[tuple[float, float]] | None = None, material: Material = Material(name='default', elastic_modulus=1, poissons_ratio=0, yield_strength=1, density=1, color='w')) Geometry[source]#

Creates Geometry from points, facets, a control point and holes.

Parameters:
  • points (list[tuple[float, float]]) – List of points (x, y) defining the vertices of the section geometry. If the geometry simply contains a continuous list of exterior points, consider creating a shapely.Polygon object (only requiring points), and create a Geometry object using the constructor.

  • facets (list[tuple[int, int]]) – A list of (start, end) indices of vertices defining the edges of the section geoemtry. Can be used to define both external and internal perimeters of holes. Facets are assumed to be described in the order of exterior perimeter, interior perimeter 1, interior perimeter 2, etc.

  • control_points (list[tuple[float, float]]) – An (x, y) coordinate that describes the distinct, contiguous, region of a single material within the geometry. Must be entered as a list of coordinates, e.g. [(0.5, 3.2)]. Exactly one point is required for each geometry with a distinct material. If there are multiple distinct regions, then use sectionproperties.pre.geometry.CompoundGeometry.from_points()

  • holes (list[tuple[float, float]] | None) – A list of points (x, y) that define interior regions as being holes or voids. The point can be located anywhere within the hole region. Only one point is required per hole region.

  • material (Material) – A Material object that is to be assigned.

Raises:

ValueError – If there is not exactly one control point specified

Returns:

Geometry object

Return type:

Geometry

Example

from sectionproperties.pre import Geometry

points = [(0, 0), (10, 5), (15, 15), (5, 10), (6, 6), (9, 7), (7, 9)]
facets = [(0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 4)]
control_points = [(4, 4)]
holes = [(7, 7)]

Geometry.from_points(
    points=points,
    facets=facets,
    control_points=control_points,
    holes=holes,
).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-1.png

Geometry created from points, facets and holes.#

static from_dxf(dxf_filepath: str | Path, spline_delta: float = 0.1, degrees_per_segment: float = 1) Geometry | CompoundGeometry[source]#

An interface for the creation of Geometry objects from CAD .dxf files.

Parameters:
  • dxf_filepath (str | Path) – A path-like object for the dxf file

  • spline_delta (float) – Splines are not supported in shapely, so they are approximated as polylines, this argument affects the spline sampling rate

  • degrees_per_segment (float) – The number of degrees discretised as a single line segment

Returns:

Geometry or CompoundGeometry object

Return type:

Geometry | CompoundGeometry

classmethod from_3dm(filepath: str | Path, **kwargs: Any) Geometry[source]#

Creates a Geometry object from a Rhino .3dm file.

Parameters:
  • filepath (str | Path) – File path to the rhino .3dm file.

  • kwargs (Any) – See below.

Keyword Arguments:
  • refine_num (Optional[int]) – Bézier curve interpolation number. In Rhino a surface’s edges are nurb based curves. Shapely does not support nurbs, so the individual Bézier curves are interpolated using straight lines. This parameter sets the number of straight lines used in the interpolation. Default is 1.

  • vec1 (Optional[numpy.ndarray]) – A 3d vector in the Shapely plane. Rhino is a 3D geometry environment. Shapely is a 2D geometric library. Thus a 2D plane needs to be defined in Rhino that represents the Shapely coordinate system. vec1 represents the 1st vector of this plane. It will be used as Shapely’s x direction. Default is [1,0,0].

  • vec2 (Optional[numpy.ndarray]) – Continuing from vec1, vec2 is another vector to define the Shapely plane. It must not be [0,0,0] and it’s only requirement is that it is any vector in the Shapely plane (but not equal to vec1). Default is [0,1,0].

  • plane_distance (Optional[float]) – The distance to the Shapely plane. Default is 0.

  • project (Optional[bool]) – Controls if the breps are projected onto the plane in the direction of the Shapley plane’s normal. Default is True.

  • parallel (Optional[bool]) – Controls if only the rhino surfaces that have the same normal as the Shapely plane are yielded. If true, all non parallel surfaces are filtered out. Default is False.

Raises:
  • RuntimeError – A RuntimeError is raised if two or more polygons are found. This is dependent on the keyword arguments. Try adjusting the keyword arguments if this error is raised.

  • ImportError – If rhino3dm is not installed. To enable rhino features use pip install sectionproperties[rhino].

Returns:

A Geometry object.

Return type:

Geometry

classmethod from_rhino_encoding(r3dm_brep: str, **kwargs: Any) Geometry[source]#

Load an encoded single surface planer brep.

Parameters:
  • r3dm_brep (str) – A Rhino3dm.Brep encoded as a string.

  • kwargs (Any) – See below.

Keyword Arguments:
  • refine_num (Optional[int]) – Bézier curve interpolation number. In Rhino a surface’s edges are nurb based curves. Shapely does not support nurbs, so the individual Bézier curves are interpolated using straight lines. This parameter sets the number of straight lines used in the interpolation. Default is 1.

  • vec1 (Optional[numpy.ndarray]) – A 3d vector in the Shapely plane. Rhino is a 3D geometry environment. Shapely is a 2D geometric library. Thus a 2D plane needs to be defined in Rhino that represents the Shapely coordinate system. vec1 represents the 1st vector of this plane. It will be used as Shapely’s x direction. Default is [1,0,0].

  • vec2 (Optional[numpy.ndarray]) – Continuing from vec1, vec2 is another vector to define the Shapely plane. It must not be [0,0,0] and it’s only requirement is that it is any vector in the Shapely plane (but not equal to vec1). Default is [0,1,0].

  • plane_distance (Optional[float]) – The distance to the Shapely plane. Default is 0.

  • project (Optional[bool]) – Controls if the breps are projected onto the plane in the direction of the Shapley plane’s normal. Default is True.

  • parallel (Optional[bool]) – Controls if only the rhino surfaces that have the same normal as the Shapely plane are yielded. If true, all non parallel surfaces are filtered out. Default is False.

Raises:

ImportError – If rhino3dm is not installed. To enable rhino features use pip install sectionproperties[rhino].

Returns:

A Geometry object found in the encoded string.

Return type:

Geometry

create_facets_and_control_points() None[source]#

Creates geometry data from shapely data.

Generates points, facets, control points, holes and perimeter from the shapely geometry.

compile_geometry() None[source]#

Alias for create_facets_and_control_points().

Alters attributes .points, .facets, .holes, .control_points to represent the data in the shapely geometry.

create_mesh(mesh_sizes: float | list[float], min_angle: float = 30.0, coarse: bool = False) Geometry[source]#

Creates a quadratic triangular mesh from the Geometry object.

Parameters:
  • mesh_sizes (float | list[float]) – A float describing the maximum mesh element area to be used within the Geometry-object finite-element mesh (may also be a list of length 1).

  • min_angle (float) – The meshing algorithm adds vertices to the mesh to ensure that no angle smaller than the minimum angle (in degrees, rounded to 1 decimal place). Note that small angles between input segments cannot be eliminated. If the minimum angle is 20.7 deg or smaller, the triangulation algorithm is theoretically guaranteed to terminate (given sufficient precision). The algorithm often doesn’t terminate for angles greater than 33 deg. Some meshes may require angles well below 20 deg to avoid problems associated with insufficient floating-point precision.

  • coarse (bool) – If set to True, will create a coarse mesh (no area or quality constraints)

Raises:

ValueErrormesh_sizes is not valid

Returns:

Geometry object with mesh data stored in .mesh attribute. Returned Geometry object is self, not a new instance.

Return type:

Geometry

Example

The following example creates a circular cross-section with a diameter of 50 mm with 64 points, and generates a mesh with a maximum triangular area of 2.5 mm2.

from sectionproperties.pre.library import circular_section
from sectionproperties.analysis import Section

geom = circular_section(d=50, n=64)
geom = geom.create_mesh(mesh_sizes=2.5)
Section(geom).plot_mesh(materials=False)

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-2.png

Mesh for a 50 mm diameter circle#

align_to(other: Geometry | CompoundGeometry | tuple[float, float], on: str, inner: bool = False) Geometry[source]#

Aligns the geometry to another Geometry object.

Returns a new Geometry object, representing self translated so that is aligned on one of the outer bounding box edges of other.

If other is a tuple representing an (x, y) coordinate, then the new Geometry object will represent ‘self’ translated so that it is aligned on that side of the point.

Parameters:
  • other (Geometry | CompoundGeometry | tuple[float, float]) – Either another Geometry or a tuple representing an (x, y) coordinate point that self should align to.

  • on (str) – A str of either “left”, “right”, “bottom”, or “top” indicating which side of other that self should be aligned to.

  • inner (bool) – If True, align self to other in such a way that self is aligned to the “inside” of other. In other words, align self to other on the specified edge so they overlap.

Returns:

Geometry object translated to alignment location

Return type:

Geometry

Example

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import triangular_section

rect = rectangular_section(b=100, d=50)
tri = triangular_section(b=50, h=50)
tri = tri.align_to(other=rect, on="top")
(rect + tri).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-3.png

A triangle aligned to the top of a rectangle.#

align_center(align_to: Geometry | tuple[float, float] | None = None) Geometry[source]#

Aligns the geometry to a center point.

Returns a new Geometry object, translated in both x and y, so that the the new object’s centroid will be aligned with the centroid of the object in align_to. If align_to is an (x, y) coordinate, then the centroid will be aligned to the coordinate. If align_to is None then the new object will be aligned with its centroid at the origin.

Parameters:

align_to (Geometry | tuple[float, float] | None) – Another Geometry to align to, an (x, y) coordinate or None

Raises:

ValueErroralign_to is not valid

Returns:

Geometry object translated to new alignment

Return type:

Geometry

Example

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import triangular_section

rect = rectangular_section(b=200, d=200)
tri = triangular_section(b=50, h=50)
tri = tri.align_center(align_to=rect)
geom = rect + tri
geom.holes = [(100, 100)]
geom.control_points = [(25, 25)]
geom.plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-4.png

A triangular hole aligned to the centre of a square.#

shift_section(x_offset: float = 0.0, y_offset: float = 0.0) Geometry[source]#

Returns a new Geometry object translated by (x_offset, y_offset).

Parameters:
  • x_offset (float) – Distance in x-direction by which to shift the geometry.

  • y_offset (float) – Distance in y-direction by which to shift the geometry.

Returns:

New Geometry object shifted by x_offset and y_offset

Return type:

Geometry

Example

from sectionproperties.pre.library import rectangular_section

rect1 = rectangular_section(b=200, d=100)
rect2 = rect1.shift_section(x_offset=100, y_offset=100)
(rect1 + rect2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-5.png

Using shift_section to shift geometry.#

rotate_section(angle: float, rot_point: tuple[float, float] | str = 'center', use_radians: bool = False) Geometry[source]#

Rotate the Geometry object.

Rotates the geometry and specified angle about a point. If the rotation point is not provided, rotates the section about the center of the geometry’s bounding box.

Parameters:
  • angle (float) – Angle (degrees by default) by which to rotate the section. A positive angle leads to a counter-clockwise rotation.

  • rot_point (tuple[float, float] | str) – Point (x, y) about which to rotate the section. If not provided, will rotate about the “center” of the geometry’s bounding box.

  • use_radians (bool) – Boolean to indicate whether angle is in degrees or radians. If True, angle is interpreted as radians.

Returns:

New Geometry object rotated by angle about rot_point

Return type:

Geometry

Example

from sectionproperties.pre.library import i_section

geom = i_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8)
geom.rotate_section(angle=-30).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-6.png

A 200UB25 section rotated clockwise by 30 degrees#

mirror_section(axis: str = 'x', mirror_point: tuple[float, float] | str = 'center') Geometry[source]#

Mirrors the geometry about a point on either the x or y-axis.

Parameters:
  • axis (str) – Axis about which to mirror the geometry, "x" or "y"

  • mirror_point (tuple[float, float] | str) – Point about which to mirror the geometry (x, y). If no point is provided, mirrors the geometry about the centroid of the shape’s bounding box.

Returns:

New Geometry object mirrored on axis about mirror_point

Return type:

Geometry

Example

The following example mirrors a 200PFC section about the y-axis:

from sectionproperties.pre.library import channel_section

geom = channel_section(d=200, b=75, t_f=12, t_w=6, r=12, n_r=8)
geom.mirror_section(axis="y", mirror_point=(0, 0)).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-7.png

A 200PFC section mirrored about the y-axis and the point (0, 0)#

split_section(point_i: tuple[float, float], point_j: tuple[float, float] | None = None, vector: tuple[float, float] | None | ndarray[Any, dtype[float64]] = None) tuple[list[Geometry], list[Geometry]][source]#

Splits geometry about a line.

Splits, or bisects, the geometry about a line, as defined by two points on the line or by one point on the line and a vector. Either point_j or vector must be given. If point_j is given, vector is ignored.

Returns a tuple of two lists each containing new Geometry instances representing the "top" and "bottom" portions, respectively, of the bisected geometry.

If the line is a vertical line then the "right" and "left" portions, respectively, are returned.

Parameters:
  • point_i (tuple[float, float]) – A tuple of (x, y) coordinates to define a first point on the line

  • point_j (tuple[float, float] | None) – A tuple of (x, y) coordinates to define a second point on the line

  • vector (tuple[float, float] | None | ndarray[Any, dtype[float64]]) – A tuple or numpy array of (x, y) components to define the line direction

Raises:

ValueError – Line definition is invalid

Returns:

A tuple of lists containing Geometry objects that are bisected about the line defined by the two given points. The first item in the tuple represents the geometries on the "top" of the line (or to the "right" of the line, if vertical) and the second item represents the geometries to the "bottom" of the line (or to the "left" of the line, if vertical).

Return type:

tuple[list[Geometry], list[Geometry]]

Example

The following example splits a 200PFC section about the x-axis at y=100:

from sectionproperties.pre.library import channel_section

geom = channel_section(d=200, b=75, t_f=12, t_w=6, r=12, n_r=8)
top_geoms, bot_geoms = geom.split_section(
    point_i=(0, 100),
    point_j=(1, 100),
)
(top_geoms[0] + bot_geoms[0]).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-8.png

A 200PFC section split about the y-axis.#

offset_perimeter(amount: float = 0.0, where: str = 'exterior', resolution: int = 12) Geometry | CompoundGeometry[source]#

Dilates or erodes the section perimeter by a discrete amount.

Parameters:
  • amount (float) – Distance to offset the section by. A negative value “erodes” the section. A positive value “dilates” the section.

  • where (str) – One of either "exterior", "interior", or "all" to specify which edges of the geometry to offset. If geometry has no interiors, then this parameter has no effect.

  • resolution (int) – Number of segments used to approximate a quarter circle around a point

Raises:
  • ValueErrorwhere is invalid

  • ValueError – Attempted to offset internally where there are no holes

Returns:

Geometry object translated to new alignment

Return type:

Geometry | CompoundGeometry

Example

The following example erodes a 200PFC section by 2 mm:

from sectionproperties.pre.library import channel_section

geom = channel_section(d=200, b=75, t_f=12, t_w=6, r=12, n_r=8)
geom.offset_perimeter(amount=-2.0).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-9.png

A 200PFC eroded by 2 mm.#

shift_points(point_idxs: int | list[int], dx: float = 0.0, dy: float = 0.0, abs_x: float | None = None, abs_y: float | None = None) Geometry[source]#

Shifts the points in the geometry.

Translates one (or many points) in the geometry by either a relative amount or to a new absolute location. Returns a new Geometry representing the original with the selected point(s) shifted to the new location.

Points are identified by their index, their relative location within the points list found in self.points. You can call self.plot_geometry(labels="points") to see a plot with the points labeled to find the appropriate point indexes.

Parameters:
  • point_idxs (int | list[int]) – An integer representing an index location or a list of integer index locations.

  • dx (float) – The number of units in the x-direction to shift the point(s) by

  • dy (float) – The number of units in the y-direction to shift the point(s) by

  • abs_x (float | None) – Absolute x-coordinate in coordinate system to shift the point(s) to. If abs_x is provided, dx is ignored. If providing a list to point_idxs, all points will be moved to this absolute location.

  • abs_y (float | None) – Absolute y-coordinate in coordinate system to shift the point(s) to. If abs_y is provided, dy is ignored. If providing a list to point_idxs, all points will be moved to this absolute location.

Returns:

Geometry object with selected points translated to the new location

Return type:

Geometry

Example

The following example expands the sides of a rectangle, one point at a time, to make it a square:

from sectionproperties.pre.library import rectangular_section

geom = rectangular_section(d=200, b=150)

# using relative shifting
geom_step_1 = geom.shift_points(point_idxs=1, dx=50)

# using absolute relocation
geom_step_1.shift_points(point_idxs=2, abs_x=200).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-10.png

Rectangle transformed to a square with shift_points#

plot_geometry(labels: tuple[str] = ('control_points',), title: str = 'Cross-Section Geometry', cp: bool = True, legend: bool = True, **kwargs: Any) matplotlib.axes.Axes[source]#

Plots the geometry defined by the input section.

Parameters:
  • labels (tuple[str]) – A tuple of str which indicate which labels to plot. Can be one or a combination of "points", "facets", "control_points", or an empty tuple to indicate no labels.

  • title (str) – Plot title

  • cp (bool) – If set to True, plots the control points

  • legend (bool) – If set to True, plots the legend

  • kwargs (Any) – Passed to plotting_context()

Returns:

Matplotlib axes object

Return type:

matplotlib.axes.Axes

calculate_extents() tuple[float, float, float, float][source]#

Calculate geometry extents.

Calculates the minimum and maximum x and y-values amongst the list of points; the points that describe the bounding box of the Geometry instance.

Returns:

Minimum and maximum x and y-values (x_min, x_max, y_min, y_max)

Return type:

tuple[float, float, float, float]

calculate_perimeter() float[source]#

Calculates the exterior perimeter of the geometry.

Returns:

Geometry perimeter

Return type:

float

calculate_area() float[source]#

Calculates the area of the geometry.

Returns:

Geometry area

Return type:

float

calculate_centroid() tuple[float, float][source]#

Calculates the centroid of the geometry.

Returns:

Geometry centroid

Return type:

tuple[float, float]

property recovery_points: list[tuple[float, float]] | list[Point]#

Returns the recovery points.

Returns:

Recovery points

__or__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry[source]#

Performs a union on Geometry objects with the | operator.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the union with

Raises:

ValueError – Unable to perform union

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example combines two rectangles using the | operator:

from sectionproperties.pre.library import rectangular_section

rect1 = rectangular_section(d=100, b=200)
rect2 = rectangular_section(d=100, b=200).shift_section(
    x_offset=150,
    y_offset=70,
)
(rect1 | rect2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-11.png

Union of two rectangles#

__xor__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry[source]#

Performs a symmetric difference on Geometry objects with the ^ operator.

Returns the regions of geometry that are not overlapping.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the symmetric difference with

Raises:

ValueError – Unable to perform symmetric difference

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example performs a symmetric difference on two circles with the ^ operator:

from sectionproperties.pre.library import circular_section
from sectionproperties.analysis import Section

circ1 = circular_section(d=100, n=64)
circ2 = circular_section(d=100, n=64).shift_section(x_offset=35)
(circ1 ^ circ2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-12.png

Symmetric difference of two circles#

__sub__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry[source]#

Performs a difference operation on Geometry objects with the - operator.

Subtracts the second geometry from the first geometry.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the difference operation with

Raises:

ValueError – Unable to perform difference

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example creates a hollow box using the - operator:

from sectionproperties.pre.library import rectangular_section

rect1 = rectangular_section(d=400, b=200)
rect2 = rectangular_section(d=300, b=100).align_center(align_to=rect1)
(rect1 - rect2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-13.png

Hollow box#

__add__(other: Geometry | CompoundGeometry) CompoundGeometry[source]#

Combine Geometry objects into a CompoundGeometry using the + operator.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the combination with

Raises:

ValueError – Unable to perform combination operation

Returns:

New Geometry object

Return type:

CompoundGeometry

Example

The following example creates a tee section the + operator:

from sectionproperties.pre.library import rectangular_section

flange = rectangular_section(d=16, b=200)
web = (
    rectangular_section(d=284, b=16)
    .align_center(align_to=flange)
    .align_to(other=flange, on="bottom")
)
(flange + web).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-14.png

Tee section#

__and__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry[source]#

Performs an intersection on Geometry objects with the & operator.

Returns the regions of geometry common to both geometries.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the intersection with

Raises:

ValueError – Unable to perform intersection

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example performs an intersection of a square and circle using the & operator:

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import circular_section

rect = rectangular_section(d=200, b=200).align_center(align_to=(0, 0))
circle = circular_section(d=250, n=64)
(rect & circle).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-Geometry-15.png

Intersection of a square and circle#