This commit is contained in:
Grant Sanderson
2020-06-09 21:24:42 -07:00
parent 8a060dfa3f
commit 2317a7d982

View File

@ -1,3 +1,5 @@
import math
from manimlib.constants import *
from manimlib.mobject.types.surface import ParametricSurface
from manimlib.mobject.types.surface import SGroup
@ -93,6 +95,19 @@ class Cylinder(ArglessSurface):
return [np.cos(u), np.sin(u), v]
class Torus(ArglessSurface):
CONFIG = {
"u_range": (0, TAU),
"v_range": (0, TAU),
"r1": 3,
"r2": 1,
}
def uv_func(self, u, v):
P = np.array([math.cos(u), math.sin(u), 0])
return (self.r1 - self.r2 * math.cos(v)) * P - math.sin(v) * OUT
class Line3D(Cylinder):
CONFIG = {
"width": 0.05,