Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge Iframe embedding
swh:1:cnt:36bd2de5308b3aee52729cea1ee1b097869ec0a6

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
#include "stretch_angles.h"

#include <TinyAD/Utils/Helpers.hh>

geometrycentral::surface::FaceData<double>
computeStretchAngles(geometrycentral::surface::ManifoldSurfaceMesh& mesh,
                     const Eigen::MatrixXd& V,
                     const Eigen::MatrixXi& F,
                     const geometrycentral::surface::FaceData<Eigen::Matrix2d>& Minv)
{
  using namespace geometrycentral;
  using namespace geometrycentral::surface;

  FaceData<double> angles(mesh);

#pragma omp parallel for schedule(static) num_threads(omp_get_max_threads() - 1)
  for(int i = 0; i < F.rows(); ++i)
  {
    // Get 3D vertex positions
    Eigen::Vector3d ar = V.row(F(i, 0));
    Eigen::Vector3d br = V.row(F(i, 1));
    Eigen::Vector3d cr = V.row(F(i, 2));
    Eigen::Matrix<double, 3, 2> Mr = TinyAD::col_mat(br - ar, cr - ar);

    // Compute deformation gradient
    Eigen::Matrix<double, 3, 2> F = Mr * Minv[i];

    // Compute first fundamental form
    Eigen::Matrix2d I = F.transpose() * F;

    // when considering the metric tensor I (instead of the differential J), the angles should be multiplied by two
    angles[i] = atan2(I(0, 1) + I(1, 0), I(0, 0) - I(1, 1));
    if(angles[i] < 0)
      angles[i] += PI;
    else
      angles[i] -= PI;
    angles[i] /= 2;
  }

  return angles;
}

geometrycentral::surface::FaceData<double> computeStretchAngles(geometrycentral::surface::ManifoldSurfaceMesh& mesh,
                                                                const Eigen::MatrixXd& V,
                                                                const Eigen::MatrixXd& P,
                                                                const Eigen::MatrixXi& F)
{
  using namespace geometrycentral;
  using namespace geometrycentral::surface;

  FaceData<double> angles(mesh);

#pragma omp parallel for schedule(static) num_threads(omp_get_max_threads() - 1)
  for(int i = 0; i < F.rows(); ++i)
  {
    // Get 3D vertex positions
    Eigen::Vector3d ar = V.row(F(i, 0));
    Eigen::Vector3d br = V.row(F(i, 1));
    Eigen::Vector3d cr = V.row(F(i, 2));
    Eigen::Matrix<double, 3, 2> Mr = TinyAD::col_mat(br - ar, cr - ar);

    // Get 2D vertex positions
    Eigen::Vector2d a = P.row(F(i, 0));
    Eigen::Vector2d b = P.row(F(i, 1));
    Eigen::Vector2d c = P.row(F(i, 2));
    Eigen::Matrix2d M = TinyAD::col_mat(b - a, c - a);

    // Compute deformation gradient
    Eigen::Matrix<double, 3, 2> F = Mr * M.inverse();

    // Compute first fundamental form
    Eigen::Matrix2d I = F.transpose() * F;

    // when considering the metric tensor I (instead of the differential J), the angles should be multiplied by two
    angles[i] = atan2(I(0, 1) + I(1, 0), I(0, 0) - I(1, 1));
    if(angles[i] < 0)
      angles[i] += PI;
    else
      angles[i] -= PI;
    angles[i] /= 2;
  }

  return angles;
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API