Source code for ddg.nets.parametrizations.spheres_and_circles

from functools import partial

import numpy as np

import ddg


[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.nets.SmoothNet """ domain = ddg.nets.SmoothInterval([0, 2 * np.pi, True]) function = partial( ddg.math.parametrizations.circle, center=center, radius=radius, normals=normals, ) return ddg.nets.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.nets.SmoothNet """ domain = ddg.nets.SmoothDomain([(0, 2 * np.pi, True), (0, np.pi, False)]) function = partial( ddg.math.parametrizations.sphere, center=center, radius=radius, ) return ddg.nets.SmoothNet(function, domain)