% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mris-remesh.R
\name{mris_remesh}
\alias{mris_remesh}
\title{Isotropic re-triangulation of a surface mesh}
\usage{
mris_remesh(
  mesh,
  target_edge_length = NULL,
  niterations = 5L,
  n_smooth = 2L,
  damping = 0.99,
  verbose = FALSE
)
}
\arguments{
\item{mesh}{triangular mesh of class \code{'mesh3d'} (or coercible via
\code{\link{ensure_mesh3d}}). The mesh \strong{must} be closed, manifold,
and genus-0 (watertight, no boundary or non-manifold edges, single
connected component); \code{mris_remesh} raises an error if such defects
are detected}

\item{target_edge_length}{numeric; desired uniform edge length in the same
units as \code{mesh$vb}. Default \code{NULL} uses the current average edge
length (quality improvement without size change)}

\item{niterations}{integer; number of split/collapse/smooth iterations.
Default \code{5}}

\item{n_smooth}{integer; number of tangential-smooth passes per iteration.
Default \code{2}}

\item{damping}{numeric; fraction of the tangential displacement applied at
each smooth pass (between 0 and 1). Default \code{0.99}}

\item{verbose}{logical; print per-iteration vertex and face counts.
Default \code{FALSE}}
}
\value{
A \code{'mesh3d'} object with \code{vb}, \code{it}, and
\code{normals}. Vertex and face counts differ from the input; the surface
geometry is preserved.
}
\description{
Re-triangulates a closed surface mesh so that all edges approach a uniform
target length, improving triangle regularity and quality without changing
the surface topology or shape. The output has a different vertex and face
count than the input but closely tracks the original surface geometry.
}
\details{
Each iteration applies three steps following the procedure described in the
\strong{References}:
\enumerate{
  \item \strong{Edge split}: every edge longer than
    \eqn{4/3 \times \code{target\_edge\_length}} is split at its midpoint.
    One-edge splits produce 2 sub-triangles; two-edge splits produce 3;
    three-edge splits produce 4 (the standard 1-to-4 uniform refinement).
  \item \strong{Edge collapse}: every edge shorter than
    \eqn{4/5 \times \code{target\_edge\_length}} is collapsed to its
    midpoint. A collapse is skipped if it would flip any surrounding
    face normal (manifold-safety check).
  \item \strong{Tangential smoothing}: \code{n_smooth} passes of
    uniform-weight 1-ring \verb{Laplacian} averaging, with each
    displacement projected onto the vertex tangent plane (the normal
    component is removed) before application. This improves vertex
    regularity while keeping vertices near the original surface.
}
After all iterations, vertex normals are refreshed.

Unlike \code{\link{vcg_uniform_remesh}}, which uses volumetric resampling
and may change topology, this function operates entirely on the mesh
surface and preserves the input genus and manifold structure.
}
\examples{

sphere <- vcg_sphere()
sphere

vcg_average_edge_length(sphere)
plot(sphere)

remeshed <- mris_remesh(
  sphere,
  target_edge_length = 0.3
)

plot(remeshed)



}
\references{
A \verb{remeshing} approach to \verb{multiresolution} modeling.
\emph{Proceedings of Shape \verb{Modelling} International}, 49-58 (2003).
}
