neighbor_based_smooth

Function neighbor_based_smooth 

Source
pub fn neighbor_based_smooth<T: CoordsFloat>(
    t: &mut Transaction,
    map: &CMap2<T>,
    vid: VertexIdType,
    neighbors_id: &[VertexIdType],
    lambda: T,
) -> StmClosureResult<()>
Expand description

Generic neighbor-based vertex smoothing function.

This function smooths the vertex position by moving it toward the average of its neighbors’ positions weighted by lambda.

Note that it is up to the user to provide a correct list of neighbor IDs, and “acceptable” lambda parameter. For example:

  • lambda == 1 nullifies the influence of the original vertex position,
  • 0 < lambda < 1 results in a Laplacian smoothing.

§Arguments

  • t: &mut Transaction – Associated transaction.
  • map: &mut CMap2 – Edited map.
  • vid: VertexIdType – Vertex to move.
  • neighbors_id: &[VertexIdType] – List of vertex to compute the average from.
  • lambda: T – Coefficient weighting the applied offset.

§Errors

This function will abort and raise an error if the transaction cannot be completed.

§Panics

This function may panic if one vertex in the neighbors_id list has no associated coordinates.