from functools import partial
import numpy as np
import ddg
import ddg.math.euclidean
[docs]def circle(center, radius=1, normals=None):
"""
Function to create a SmoothNet representing a circle embedded in d-dimensional
Euclidean space.
Parameters
----------
center: np.array of shape (d,)
Center of the circle.
radius: float (default=1)
Radius of the circle.
normals: np.array of shape (n, d) (default=None)
Normals of the circle that determine the orthogonal complement of the
subspace containing the circle.
If None are given the orthogonal complement will be determined by the
dimension of the center and its normals consist of unit normal vectors.
Returns
-------
ddg.SmoothNet
"""
domain = ddg.nets.SmoothInterval([0, 2 * np.pi, True])
function = partial(
ddg.math.euclidean.circle_fct, center=center, radius=radius, normals=normals
)
return ddg.SmoothCurve(function, domain)
[docs]def sphere(center, radius=1):
"""
Function to create a SmoothNet representing a 2d sphere embedded in 3d
Euclidean space.
Parameters
----------
center: np.array of shape (3,)
Center of the sphere.
radius: float (default=1)
Radius of the sphere.
Returns
-------
ddg.SmoothNet
"""
domain = ddg.nets.SmoothDomain([(0, 2 * np.pi, True), (0, np.pi, False)])
function = partial(ddg.math.euclidean.sphere_fct, center=center, radius=radius)
return ddg.SmoothNet(function, domain)