メインコンテンツまでスキップ

Torus

ライブエディター

function Canvas() {
      const geo = torus({ radius: 0.5, tube: 0.25, radialSegments: 8, tubularSegments: 32 })
      const mat = rotate3dX(iMouse.y.negate()).mul(rotate3dY(iMouse.x))
      const gl = useGL({
              isWebGL: true,
              isDepth: true,
              count: geo.count,
              vertex: vec4(mat.mul(geo.vertex), 1),
              fragment: vec4(varying(geo.normal), 1),
      })
      return <canvas ref={gl.ref} />
}
結果
Loading...

Torus Props

radiusMajor radius from torus center to tube center.
Default is 1.
tubeMinor radius of the tube cross-section.
Default is 0.4.
radialSegmentsNumber of segments around the tube circumference.
Default is 12.
tubularSegmentsNumber of segments along the torus circumference.
Default is 48.
arcCentral angle sweep in radians.
Default is Math.PI*2.

Parametric Surface Definition

The torus represents a surface of revolution generated by rotating a circle around a coaxial axis. The mathematical definition employs two angular parameters forming a coordinate system on the surface.

x(u,v)=(R+rcosv)cosuy(u,v)=(R+rcosv)sinuz(u,v)=rsinv\begin{aligned} x(u,v) &= (R + r\cos v) \cos u \\ y(u,v) &= (R + r\cos v) \sin u \\ z(u,v) &= r \sin v \end{aligned}

Where u[0,2π]u \in [0, 2\pi] parameterizes the major circumference and v[0,2π]v \in [0, 2\pi] parameterizes the minor circumference. The major radius RR controls the distance from the central axis to the tube center, while the minor radius rr determines the tube thickness.

Surface Normal Calculation

The normal vectors are computed by taking the cross product of the partial derivatives with respect to both parameters. For a torus, the normal at any point (u,v)(u,v) points radially outward from the nearest point on the central axis.

n(u,v)=ru×rv\vec{n}(u,v) = \frac{\partial \vec{r}}{\partial u} \times \frac{\partial \vec{r}}{\partial v}

The resulting normal vector simplifies to:

n(u,v)=(cosvcosu,cosvsinu,sinv)\vec{n}(u,v) = (\cos v \cos u, \cos v \sin u, \sin v)

Topological Properties

The torus exhibits genus-1 topology, containing exactly one handle. This fundamental property distinguishes it from spherical surfaces (genus-0) and creates non-trivial parametric relationships across the surface.

The ratio rR\frac{r}{R} determines the torus type. When r<Rr < R, a standard torus forms. As rr approaches RR, the inner hole shrinks. When r>Rr > R, the surface develops a self-intersection, creating a spindle torus configuration.