mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Torus
This commit is contained in:
parent
8a060dfa3f
commit
2317a7d982
1 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import math
|
||||||
|
|
||||||
from manimlib.constants import *
|
from manimlib.constants import *
|
||||||
from manimlib.mobject.types.surface import ParametricSurface
|
from manimlib.mobject.types.surface import ParametricSurface
|
||||||
from manimlib.mobject.types.surface import SGroup
|
from manimlib.mobject.types.surface import SGroup
|
||||||
|
@ -93,6 +95,19 @@ class Cylinder(ArglessSurface):
|
||||||
return [np.cos(u), np.sin(u), v]
|
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):
|
class Line3D(Cylinder):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"width": 0.05,
|
"width": 0.05,
|
||||||
|
|
Loading…
Add table
Reference in a new issue