microstructpy.geometry.n_sphere.NSphere¶

class
microstructpy.geometry.n_sphere.
NSphere
(**kwargs)[source]¶ Bases:
object
An Ndimensional sphere.
This class represents a generic, ndimensional sphere. It is defined by a center point and size parameter, which can be either radius or diameter.
If multiple size or position keywords are given, there is no guarantee whhich keywords are used to create the geometry.
 Parameters

approximate
()[source]¶ Approximate the nsphere with itself
Other geometries can be approximated by a set of circles or spheres. For the nsphere, this approximation is exact.
 Returns
A list containing [(x, y, z, …, r)]
 Return type

classmethod
best_fit
(points)[source]¶ Find nsphere of best fit for set of points.
This function takes a list of points and computes an nsphere of best fit, in an algebraic sense. This method was developed using the a published writeup, which was extended from 2D to ND. 1
 Parameters
points (list, numpy.ndarray) – List of points to fit.
 Returns
An instance of the class that fits the points.
 Return type
 1
Circle fitting writup by Randy Bullock, https://dtcenter.org/met/users/docs/write_ups/circle_fit.pdf

reflect
(points)[source]¶ Reflect points across surface.
This function reflects a point or set of points across the surface of the nsphere. Points at the center of the nsphere are not reflected.
 Parameters
points (list or numpy.ndarray) – Points to reflect.
 Returns
Reflected points.
 Return type

within
(points)[source]¶ Test if points are within nsphere.
This function tests whether a point or set of points are within the nsphere. For the set of points, a list of booleans is returned to indicate which points are within the nsphere.
 Parameters
points (list or numpy.ndarray) – Point or list of points.
 Returns
Set to True for points in geometry.
 Return type