microstructpy.geometry.circle module

class microstructpy.geometry.circle.Circle(**kwargs)[source]

Bases: microstructpy.geometry.n_sphere.NSphere

A 2D circle.

This class represents a two-dimensional circle. It is defined by a center point and size parameter, which can be either radius or diameter.

Parameters:
  • r (float, optional) – The radius of the circle. Defaults to 1.
  • center (list, optional) – The coordinates of the center. Defaults to (0, 0).
  • diameter – Alias for 2x r.
  • radius – Alias for r.
  • d – Alias for 2x r.
  • size – Alias for 2x r.
  • position – Alias for center.
classmethod area_expectation(**kwargs)[source]

Expected value of area.

This function computes the expected value for the area of a circle. The keyword arguments are the same as the class parameters. The values can be constants (ints or floats), or scipy.stats distributions.

The expected value is computed by the following formula:

\[\mathbb{E}[A] = \pi \mathbb{E}[R^2] = \pi (\mu_R^2 + \sigma_R^2)\]

For example:

>>> from microstructpy.geometry import Circle
>>> Circle.area_expectation(r=1)
3.141592653589793
>>> from scipy.stats import norm
>>> Circle.area_expectation(r=norm(1, 1))
6.283185307179586
Parameters:**kwargs – Keyword arguments, see microstructpy.geometry.Circle.
Returns:Expected value of the area of the circle.
Return type:float
plot(**kwargs)[source]

Plot the circle.

This function adds a matplotlib.patches.Circle to the current axes. The keyword arguments are passed through to the circle patch.

Parameters:**kwargs (dict) – Keyword arguments for matplotlib.
area

area of cirle, \(A=\pi r^2\)

Type:float
n_dim

number of dimensions, 2

Type:int
volume

alias for area

Type:float