Skip to contents

A parametric 3D surface defined by a function f(u, v) -> (x, y, z). The surface is tessellated into a grid of quadrilateral patches, each represented as VMobject submobjects for rendering.

Details

Based on Manim's Surface class. The surface is created by evaluating the parametric function on a regular (u, v) grid and creating a mesh of flat quadrilateral patches. Each patch can be individually colored using a color function.

Public fields

func

Parametric function f(u, v) -> c(x, y, z)

u_range

Range for u parameter c(min, max)

v_range

Range for v parameter c(min, max)

u_resolution

Number of subdivisions in u

v_resolution

Number of subdivisions in v

color_func

Optional function(x,y,z) -> hex color

checkerboard_colors

Two-color checkerboard pattern

mesh_lines

Whether to draw mesh lines

Methods

Inherited methods


Method new()

Create a parametric Surface

Usage

Surface$new(
  func,
  u_range = c(0, TAU),
  v_range = c(0, PI),
  u_resolution = 32,
  v_resolution = 32,
  color = BLUE,
  fill_opacity = 0.8,
  color_func = NULL,
  checkerboard_colors = NULL,
  mesh_lines = FALSE,
  ...
)

Arguments

func

Function(u, v) returning c(x, y, z)

u_range

c(min, max) for u parameter

v_range

c(min, max) for v parameter

u_resolution

Grid resolution in u

v_resolution

Grid resolution in v

color

Surface color

fill_opacity

Surface opacity

color_func

Optional per-point coloring function

checkerboard_colors

Two colors for checkerboard pattern

mesh_lines

Draw wireframe mesh

...

Additional args


Method set_color_by_function()

Set a color function for the surface

Usage

Surface$set_color_by_function(func)

Arguments

func

Function(x, y, z) -> hex color string


Method set_color_by_z()

Color the surface by z-value using a gradient

Usage

Surface$set_color_by_z(colors = c(BLUE, GREEN, YELLOW, RED), z_range = NULL)

Arguments

colors

Vector of colors for the gradient

z_range

Optional c(min, max) range


Method get_mesh()

Get the mesh grid points (u_res+1 x v_res+1 x 3 array)

Usage

Surface$get_mesh()


Method clone()

The objects of this class are cloneable with this method.

Usage

Surface$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.