Use Laplace equation to diffuse an attribute (number or Array) given some constraints at nodes on triangulated surface.

Example

Diffuse a scalar field

const diff = new geom.HarmonicDiffusion(positions, indices)
laplace.constrainsBorders(-1)
laplace.addConstraint([-800,-300,-800], 1)
laplace.addConstraint([ 0,-300, 800], 1)
const dataframe = diff.solve({name='P'}) // Serie.itemSize = 1

Example

Diffuse a vector field of size 3

const diff = new geom.HarmonicDiffusion(positions, indices, [0,0,0])
laplace.constrainsBorders( [-1, -2, -3])
laplace.addConstraint([-800,-300,-800], [ 3, 2, 1])
laplace.addConstraint([ 0,-300, 800], [ 1, 3, 5])
const dataframe = diff.solve({name='P', record: true}) // Serie.itemSize = 3

Hierarchy

  • HarmonicDiffusion

Constructors

  • Parameters

    • positions: Serie<IArray>

      The node positions

    • indices: Serie<IArray>

      The indices of the triangles

    • initValue: number | Data = 0

      The init value tells what kind of data we are going to diffuse. This can be either a scalar or an array of any size. The size of the array will be the itemSize of the returned Serie after calling solve() The itemSize of the returned Serie (after calling solve()) will be the length of this array, or 1 if a number is passed.

    Returns HarmonicDiffusion

Properties

constrainedNodes: Node[] = []
dataSize: number = 1
eps_: number = 0.382e-5
epsilon_: number = 0.5
map: Map<Node, Data> = ...
maxIter_: number = 618
surface_: Surface = undefined

Accessors

  • set eps(n: number): void
  • Parameters

    • n: number

    Returns void

  • set epsilon(n: number): void
  • Parameters

    • n: number

    Returns void

  • set maxIter(n: number): void
  • Parameters

    • n: number

    Returns void

Methods

  • Parameters

    • n: Node | Point
    • value: number | Data

    Returns void

  • Convenient method to constrain all the borders

    Parameters

    • value: number | Data

    Returns void

  • Solve the discrete laplace equation using relaxation

    Returns

    A DataFrame containing positions, indices series as well as the computed "property" as a serie. If record=true, a serie will be recorded every step. If step=0, only the begining step is recorded.

    Parameters

    • __namedParameters: {
          name?: string;
          record?: boolean;
          step?: number;
      }
      • Optional name?: string
      • Optional record?: boolean
      • Optional step?: number

    Returns DataFrame