Back

BarycentricMapperTriangleSetTopology

The `BarycentricMapperTriangleSetTopology` is a SOFA component designed for barycentric mapping computation on TriangleSetTopologies within the simulation framework. It inherits from `BarycentricMapperTopologyContainer`, providing specialized methods to handle barycentric coordinates and triangle elements. This mapper facilitates the transformation of points based on their positions relative to triangle vertices, which is crucial for maintaining accurate mappings between different representations or resolutions in simulations. The component interacts with other SOFA components through its template parameters (`In` and `Out`), enabling it to work seamlessly with various vector types (e.g., Vec3). The public methods include `addPointInTriangle`, `createPointInTriangle`, and the protected methods like `getElements`, `computeBase`, `computeCenter`, and `computeDistance`. These methods enable the computation of barycentric coordinates, handling of triangle elements, and distance calculations, essential for maintaining correct mappings in simulations. Practical usage involves creating instances to map points within triangles based on their barycentric coordinates. The component ensures consistency between different topologies or resolutions by leveraging these mapping operations.

abstract
The `BarycentricMapperTriangleSetTopology` computes barycentric mappings for points within TriangleSetTopologies in SOFA simulations, facilitating precise transformations based on triangle vertices.
sheet
# BarycentricMapperTriangleSetTopology ## Overview This component handles barycentric mapping computations on TriangleSetTopologies. It inherits from `BarycentricMapperTopologyContainer` and provides methods to add points within triangles using their barycentric coordinates, compute base matrices, centroids, and distances. ## Mathematical Model ### Barycentric Coordinates Given a triangle with vertices \(A\), \(B\), and \(C\), any point \(P\) inside the triangle can be expressed as: egin{equation} P = uA + vB + wC, ag{1}\end{equation} where \(u, v, w\) are the barycentric coordinates satisfying: egin{equation} u + v + w = 1. ag{2}\end{equation} ### Barycentric Mapping Operations - **addPointInTriangle**: Adds a point within a triangle based on its barycentric coordinates \((u, v)\). - **createPointInTriangle**: Creates a new point inside the triangle by defining its coordinates relative to the vertices. ## Dependencies and Connections This component typically requires TriangleSetTopology elements and interacts with other SOFA components through template parameters (`In` and `Out`). It is used in conjunction with other mapping or topology components to maintain accurate mappings between different representations or resolutions.
description
The `BarycentricMapperTriangleSetTopology` is a SOFA component designed for barycentric mapping computation on TriangleSetTopologies within the simulation framework. It inherits from `BarycentricMapperTopologyContainer`, providing specialized methods to handle barycentric coordinates and triangle elements. This mapper facilitates the transformation of points based on their positions relative to triangle vertices, which is crucial for maintaining accurate mappings between different representations or resolutions in simulations. The component interacts with other SOFA components through its template parameters (`In` and `Out`), enabling it to work seamlessly with various vector types (e.g., Vec3). The public methods include `addPointInTriangle`, `createPointInTriangle`, and the protected methods like `getElements`, `computeBase`, `computeCenter`, and `computeDistance`. These methods enable the computation of barycentric coordinates, handling of triangle elements, and distance calculations, essential for maintaining correct mappings in simulations. Practical usage involves creating instances to map points within triangles based on their barycentric coordinates. The component ensures consistency between different topologies or resolutions by leveraging these mapping operations.
maths
### Mathematical Description The `BarycentricMapperTriangleSetTopology` is designed to handle barycentric mapping computations on a TriangleSetTopology. Barycentric coordinates are a form of coordinate system that specifies the location of a point within a triangle based on ratios of distances from the vertices of the triangle. This system provides a robust and mathematically elegant way to interpolate values within triangles, which is crucial for many applications in computational geometry and physics-based simulations. #### Barycentric Coordinates Given a triangle with vertices \(A\), \(B\), and \(C\), any point \(P\) inside the triangle can be expressed as a weighted sum of these vertices using barycentric coordinates: \[ P = uA + vB + wC, \] where \(u, v, w\) are the weights satisfying: \[ u + v + w = 1. \] The triplet \((u, v, w)\) represents the barycentric coordinates of point \(P\). #### Barycentric Mapping Operations The `BarycentricMapperTriangleSetTopology` component provides several operations to manage and compute these barycentric mappings: 1. **addPointInTriangle**: Adds a point within a triangle based on its barycentric coordinates \((u, v)\). The method computes the position of the new point using the formula above. 2. **createPointInTriangle**: Creates a new point inside the triangle by defining its coordinates relative to the vertices and adjusting according to the provided vector type (e.g., `Vec3`). This involves calculating barycentric coefficients from given distances or vectors. #### Matrix Operations for Triangles Several methods in this component work with matrices to perform operations related to triangles: - **computeBase**: Computes a base matrix that represents transformations within the triangle. Given vertices \(A, B, C\), it calculates the transformation matrix used to map points from one coordinate system to another. - **computeCenter**: Calculates the centroid of a triangle by averaging its vertex coordinates, which is useful for various center-of-mass calculations or geometric operations. #### Distance Calculations The `BarycentricMapperTriangleSetTopology` also includes methods for distance calculations, ensuring that points lie within the boundaries defined by barycentric constraints. The `computeDistance` method calculates distances and ensures that any point \(P\) lies inside the triangle by verifying its barycentric coordinates fall within valid ranges. ### Physical Description The physical interpretation of this component revolves around the transformation and mapping of points in 3D space using triangles as basic elements. This is particularly useful in finite element methods, where each element (triangle) can have varying properties or deformations, requiring precise point transformations to maintain accurate simulations. In physics-based simulations, such mappings are critical for maintaining consistency across different resolutions or levels of detail. For instance, when simulating cloth or elastic materials, points within triangles need to be accurately mapped and interpolated to ensure realistic deformation behaviors. The barycentric coordinates enable this by providing a uniform way to handle transformations relative to the triangle's vertices. The component facilitates these mappings through its methods and ensures that any point transformation adheres to the constraints of barycentric space, thereby ensuring physically meaningful results in simulations.
{
  "name": "BarycentricMapperTriangleSetTopology",
  "main": {
    "name": "BarycentricMapperTriangleSetTopology",
    "namespace": "sofa::component::mapping::linear",
    "module": "Sofa.Component.Mapping.Linear",
    "include": "sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperTriangleSetTopology.h",
    "doc": "Class allowing barycentric mapping computation on a TriangleSetTopology",
    "inherits": [
      "BarycentricMapperTopologyContainer"
    ],
    "templates": [
      "sofa::sofa::defaulttype::Vec3Types, sofa::sofa::defaulttype::Vec3Types"
    ],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "addPointInTriangle",
        "return_type": "int",
        "params": [
          {
            "name": "triangleIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "createPointInTriangle",
        "return_type": "int",
        "params": [
          {
            "name": "p",
            "type": "const typename Out::Coord &"
          },
          {
            "name": "triangleIndex",
            "type": "int"
          },
          {
            "name": "points",
            "type": "const typename In::VecCoord *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getElements",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getBarycentricCoefficients",
        "return_type": "int",
        "params": [
          {
            "name": "barycentricCoordinates",
            "type": "const int &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "computeBase",
        "return_type": "void",
        "params": [
          {
            "name": "base",
            "type": "Mat3x3 &"
          },
          {
            "name": "in",
            "type": "const typename In::VecCoord &"
          },
          {
            "name": "element",
            "type": "const Triangle &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "computeCenter",
        "return_type": "void",
        "params": [
          {
            "name": "center",
            "type": "Vec3 &"
          },
          {
            "name": "in",
            "type": "const typename In::VecCoord &"
          },
          {
            "name": "element",
            "type": "const Triangle &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "computeDistance",
        "return_type": "void",
        "params": [
          {
            "name": "d",
            "type": "SReal &"
          },
          {
            "name": "v",
            "type": "const Vec3 &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "addPointInElement",
        "return_type": "void",
        "params": [
          {
            "name": "elementIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      }
    ]
  },
  "desc": {
    "description": "The `BarycentricMapperTriangleSetTopology` is a SOFA component designed for barycentric mapping computation on TriangleSetTopologies within the simulation framework. It inherits from `BarycentricMapperTopologyContainer`, providing specialized methods to handle barycentric coordinates and triangle elements.\n\nThis mapper facilitates the transformation of points based on their positions relative to triangle vertices, which is crucial for maintaining accurate mappings between different representations or resolutions in simulations. The component interacts with other SOFA components through its template parameters (`In` and `Out`), enabling it to work seamlessly with various vector types (e.g., Vec3).\n\nThe public methods include `addPointInTriangle`, `createPointInTriangle`, and the protected methods like `getElements`, `computeBase`, `computeCenter`, and `computeDistance`. These methods enable the computation of barycentric coordinates, handling of triangle elements, and distance calculations, essential for maintaining correct mappings in simulations.\n\nPractical usage involves creating instances to map points within triangles based on their barycentric coordinates. The component ensures consistency between different topologies or resolutions by leveraging these mapping operations."
  },
  "maths": {
    "maths": "### Mathematical Description\n\nThe `BarycentricMapperTriangleSetTopology` is designed to handle barycentric mapping computations on a TriangleSetTopology. Barycentric coordinates are a form of coordinate system that specifies the location of a point within a triangle based on ratios of distances from the vertices of the triangle. This system provides a robust and mathematically elegant way to interpolate values within triangles, which is crucial for many applications in computational geometry and physics-based simulations.\n\n#### Barycentric Coordinates\n\nGiven a triangle with vertices \\(A\\), \\(B\\), and \\(C\\), any point \\(P\\) inside the triangle can be expressed as a weighted sum of these vertices using barycentric coordinates:\n\\[\nP = uA + vB + wC,\n\\]\nwhere \\(u, v, w\\) are the weights satisfying:\n\\[\nu + v + w = 1.\n\\]\nThe triplet \\((u, v, w)\\) represents the barycentric coordinates of point \\(P\\).\n\n#### Barycentric Mapping Operations\n\nThe `BarycentricMapperTriangleSetTopology` component provides several operations to manage and compute these barycentric mappings:\n\n1. **addPointInTriangle**: Adds a point within a triangle based on its barycentric coordinates \\((u, v)\\). The method computes the position of the new point using the formula above.\n2. **createPointInTriangle**: Creates a new point inside the triangle by defining its coordinates relative to the vertices and adjusting according to the provided vector type (e.g., `Vec3`). This involves calculating barycentric coefficients from given distances or vectors.\n\n#### Matrix Operations for Triangles\n\nSeveral methods in this component work with matrices to perform operations related to triangles:\n\n- **computeBase**: Computes a base matrix that represents transformations within the triangle. Given vertices \\(A, B, C\\), it calculates the transformation matrix used to map points from one coordinate system to another.\n- **computeCenter**: Calculates the centroid of a triangle by averaging its vertex coordinates, which is useful for various center-of-mass calculations or geometric operations.\n\n#### Distance Calculations\n\nThe `BarycentricMapperTriangleSetTopology` also includes methods for distance calculations, ensuring that points lie within the boundaries defined by barycentric constraints. The `computeDistance` method calculates distances and ensures that any point \\(P\\) lies inside the triangle by verifying its barycentric coordinates fall within valid ranges.\n\n### Physical Description\n\nThe physical interpretation of this component revolves around the transformation and mapping of points in 3D space using triangles as basic elements. This is particularly useful in finite element methods, where each element (triangle) can have varying properties or deformations, requiring precise point transformations to maintain accurate simulations.\n\nIn physics-based simulations, such mappings are critical for maintaining consistency across different resolutions or levels of detail. For instance, when simulating cloth or elastic materials, points within triangles need to be accurately mapped and interpolated to ensure realistic deformation behaviors. The barycentric coordinates enable this by providing a uniform way to handle transformations relative to the triangle's vertices.\n\nThe component facilitates these mappings through its methods and ensures that any point transformation adheres to the constraints of barycentric space, thereby ensuring physically meaningful results in simulations."
  },
  "summary": {
    "abstract": "The `BarycentricMapperTriangleSetTopology` computes barycentric mappings for points within TriangleSetTopologies in SOFA simulations, facilitating precise transformations based on triangle vertices.",
    "sheet": "# BarycentricMapperTriangleSetTopology\n\n## Overview\n\nThis component handles barycentric mapping computations on TriangleSetTopologies. It inherits from `BarycentricMapperTopologyContainer` and provides methods to add points within triangles using their barycentric coordinates, compute base matrices, centroids, and distances.\n\n## Mathematical Model\n\n### Barycentric Coordinates\nGiven a triangle with vertices \\(A\\), \\(B\\), and \\(C\\), any point \\(P\\) inside the triangle can be expressed as:\n\begin{equation}\n  P = uA + vB + wC,\n\tag{1}\\end{equation}\nwhere \\(u, v, w\\) are the barycentric coordinates satisfying:\n\begin{equation}\n  u + v + w = 1.\n\tag{2}\\end{equation}\n\n### Barycentric Mapping Operations\n- **addPointInTriangle**: Adds a point within a triangle based on its barycentric coordinates \\((u, v)\\).\n- **createPointInTriangle**: Creates a new point inside the triangle by defining its coordinates relative to the vertices.\n\n## Dependencies and Connections\nThis component typically requires TriangleSetTopology elements and interacts with other SOFA components through template parameters (`In` and `Out`). It is used in conjunction with other mapping or topology components to maintain accurate mappings between different representations or resolutions."
  }
}