Back

FixedLagrangianConstraint

The `FixedLagrangianConstraint` is part of the SOFA framework and serves to fix Degrees of Freedom (DOFs) in a model, enforcing Lagrangian-based constraints on specified points or all points if configured to do so. This component inherits from the more general `LagrangianConstraint`, indicating its role within the constraint hierarchy for mechanical systems. The primary interaction occurs with other SOFA components through methods such as `buildConstraintMatrix`, which constructs the matrix representing the constraint, and `getConstraintViolation` and `getConstraintResolution`, which compute how constraints are violated or resolved. This ensures that points in a model remain fixed according to user-specified parameters. The component supports various data types including vectors of different sizes (1D, 2D, 3D, 6D) and rigid body types (`Rigid3Types`). It includes a boolean parameter `fixAll` which, if set to true, fixes all points in the model. The constraint can be applied selectively using indices as well. Usage of this component involves setting up the mechanical state where constraints are needed and configuring parameters such as `d_indices`, which specifies which points to fix. If `fixAll` is enabled, all points will be fixed without needing to specify individual indices.

abstract
The `FixedLagrangianConstraint` enforces Lagrangian-based constraints on specified Degrees of Freedom (DOFs) in a SOFA simulation, fixing either selected or all points according to user-defined parameters.
sheet
# FixedLagrangianConstraint ## Overview The `FixedLagrangianConstraint` is part of the SOFA framework and enforces Lagrangian-based constraints on specified Degrees of Freedom (DOFs) in a mechanical model. It inherits from the more general `LagrangianConstraint`, indicating its role within the constraint hierarchy for mechanical systems. ## Mathematical Model The component uses a matrix representation for its constraints, denoted as \(\mathbf{C}\). Each row of this matrix corresponds to an individual constraint equation: - **For all points** (`fixAll = true`): The constraint matrix spans the entire domain of DOFs in the model. - **Selective Points**: If specific indices are provided through `d_indices`, only those corresponding rows in the matrix will be active to enforce constraints on those particular points. The constraint equations can be written as: \[ \mathbf{C} \cdot \mathbf{x} = 0 \] where \(\mathbf{x}\) is the vector of DOFs (positions and orientations). Each row in \(\mathbf{C}\) corresponds to a specific constraint equation enforcing that certain components of \(\mathbf{x}\) remain fixed. ### Constraint Matrix Construction Example for Different Data Types: - **Vec1Types**: Constraints are applied on 1D DOFs (e.g., scalar positions). \[ \mathbf{C}_{\text{Vec1}} = [1] \] - **Vec2Types**: Constraints are applied on 2D DOFs. \[ \mathbf{C}_{\text{Vec2}} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \] - **Vec3Types**: Constraints are applied on 3D positions. \[ \mathbf{C}_{\text{Vec3}} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \] - **Vec6Types**: Constraints are applied on 6D DOFs (e.g., positions and orientations). \[ \mathbf{C}_{\text{Vec6}} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \] - **Rigid3Types**: Constraints are applied on rigid body positions and orientations. \[ \mathbf{x}_{\text{rigid}} = [x, y, z, \theta_x, \theta_y, \theta_z]^T \] \[ \mathbf{C}_{\text{Rigid3}} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \] ### Constraint Violation and Resolution The `getConstraintViolation` method computes the violation of constraints, which is the difference between the current state and the fixed state. This can be represented as: \[ \mathbf{v}_{\text{viol}} = \mathbf{C} \times (\mathbf{x}_{\text{current}} - \mathbf{x}_{\text{fixed}}) \] where \(\mathbf{x}_{\text{current}}\) is the current configuration and \(\mathbf{x}_{\text{fixed}}\) is the fixed configuration. The `getConstraintResolution` method ensures that any violation of these constraints is resolved by applying appropriate forces or impulses to enforce the constraints. This typically involves solving a system of linear equations derived from the constraint matrix \(\mathbf{C}\). ## Parameters and Data - **fixAll**: If true, fix all points in the model. - Type: `bool` - Default: Not specified (depends on configuration)
description
The `FixedLagrangianConstraint` is part of the SOFA framework and serves to fix Degrees of Freedom (DOFs) in a model, enforcing Lagrangian-based constraints on specified points or all points if configured to do so. This component inherits from the more general `LagrangianConstraint`, indicating its role within the constraint hierarchy for mechanical systems. The primary interaction occurs with other SOFA components through methods such as `buildConstraintMatrix`, which constructs the matrix representing the constraint, and `getConstraintViolation` and `getConstraintResolution`, which compute how constraints are violated or resolved. This ensures that points in a model remain fixed according to user-specified parameters. The component supports various data types including vectors of different sizes (1D, 2D, 3D, 6D) and rigid body types (`Rigid3Types`). It includes a boolean parameter `fixAll` which, if set to true, fixes all points in the model. The constraint can be applied selectively using indices as well. Usage of this component involves setting up the mechanical state where constraints are needed and configuring parameters such as `d_indices`, which specifies which points to fix. If `fixAll` is enabled, all points will be fixed without needing to specify individual indices.
maths
# Mathematical and Physical Description of FixedLagrangianConstraint ## Overview The `FixedLagrangianConstraint` is a component within the Simulation Open Framework Architecture (SOFA) framework that enforces constraints on Degrees of Freedom (DOFs) in mechanical models. This constraint ensures that specified points or all points in the model remain fixed according to Lagrangian mechanics principles. ## Mathematical Formulation ### Constraint Matrix Construction The `FixedLagrangianConstraint` uses a matrix representation for its constraints, denoted as \( extbf{C} \). Each row of this matrix corresponds to an individual constraint equation. For a given set of points (DOFs) to be fixed: 1. **For all points** (`fixAll = true`): The constraint matrix is constructed such that it spans the entire domain of DOFs in the model, effectively fixing each point. 2. **Selective Points**: If specific indices are provided through `d_indices`, only those corresponding rows in the matrix will be active to enforce constraints on those particular points. ### Constraint Equations The constraint equations can be written as: \[ extbf{C} \cdot \mathbf{x} = 0 \] where \( \mathbf{x} \) is the vector of DOFs (positions and orientations). Each row in \( extbf{C} \) corresponds to a specific constraint equation enforcing that certain components of \( \mathbf{x} \) remain fixed. ### Constraint Matrix Construction Example for Different Data Types: - **Vec1Types**: Constraints are applied on 1D DOFs (e.g., scalar positions). \[ extbf{C}_{ ext{Vec1}} = [1] \] - **Vec2Types**: Constraints are applied on 2D DOFs. \[ extbf{C}_{ ext{Vec2}} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \] - **Vec3Types**: Constraints are applied on 3D positions. \[ extbf{C}_{ ext{Vec3}} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \] - **Vec6Types**: Constraints are applied on 6D DOFs (e.g., positions and orientations). \[ extbf{C}_{ ext{Vec6}} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \] - **Rigid3Types**: Constraints are applied on rigid body positions and orientations. \[ \textbf{x}_{ ext{rigid}} = [x, y, z, \theta_x, \theta_y, \theta_z]^T \] \[ extbf{C}_{ ext{Rigid3}} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \] ### Constraint Violation and Resolution The `getConstraintViolation` method computes the violation of constraints, which is the difference between the current state and the fixed state. This can be represented as: \[ extbf{v}_{ ext{viol}} = extbf{C} imes ( extbf{x}_{ ext{current}} - \textbf{x}_{ ext{fixed}}) \] where \( extbf{x}_{ ext{current}} \) is the current configuration and \( \textbf{x}_{ ext{fixed}} \) is the fixed configuration. The `getConstraintResolution` method ensures that any violation of these constraints is resolved by applying appropriate forces or impulses to enforce the constraints. This typically involves solving a system of linear equations derived from the constraint matrix \( extbf{C} \). ## Physical Interpretation In physical terms, this constraint acts as an idealized force field that prevents specified points in the model from moving beyond their initial positions (or orientations). When applied to mechanical systems such as deformable bodies or rigid bodies, it ensures that certain parts of these systems remain stationary during simulation. By fixing specific DOFs, the `FixedLagrangianConstraint` can simulate scenarios where parts of a system are held in place by external supports or constraints, providing more realistic and controllable simulations.
{
  "name": "FixedLagrangianConstraint",
  "main": {
    "name": "FixedLagrangianConstraint",
    "namespace": "sofa::component::constraint::lagrangian::model",
    "module": "Sofa.Component.Constraint.Lagrangian.Model",
    "include": "sofa/component/constraint/lagrangian/model/FixedLagrangianConstraint.h",
    "doc": "Lagrangian-based fixation of DOFs of the model.",
    "inherits": [
      "LagrangianConstraint"
    ],
    "templates": [
      "sofa::defaulttype::Rigid3Types",
      "sofa::defaulttype::Vec6Types"
    ],
    "data_fields": [
      {
        "name": "d_fixAll",
        "type": "bool",
        "xmlname": "fixAll",
        "help": "If true, fix all points"
      }
    ],
    "links": [],
    "methods": [
      {
        "name": "getConstraintIdentifiers",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getFixedIdentifiers",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "init",
        "return_type": "void",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "buildConstraintMatrix",
        "return_type": "void",
        "params": [
          {
            "name": "cParams",
            "type": "const core::ConstraintParams *"
          },
          {
            "name": "c_d",
            "type": "DataMatrixDeriv &"
          },
          {
            "name": "cIndex",
            "type": "unsigned int &"
          },
          {
            "name": "x",
            "type": "const DataVecCoord &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getConstraintViolation",
        "return_type": "void",
        "params": [
          {
            "name": "cParams",
            "type": "const core::ConstraintParams *"
          },
          {
            "name": "resV",
            "type": "linearalgebra::BaseVector *"
          },
          {
            "name": "x",
            "type": "const DataVecCoord &"
          },
          {
            "name": "v",
            "type": "const DataVecDeriv &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getConstraintResolution",
        "return_type": "void",
        "params": [
          {
            "name": "",
            "type": "const core::ConstraintParams *"
          },
          {
            "name": "resTab",
            "type": "int &"
          },
          {
            "name": "offset",
            "type": "unsigned int &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `FixedLagrangianConstraint` is part of the SOFA framework and serves to fix Degrees of Freedom (DOFs) in a model, enforcing Lagrangian-based constraints on specified points or all points if configured to do so. This component inherits from the more general `LagrangianConstraint`, indicating its role within the constraint hierarchy for mechanical systems.\n\nThe primary interaction occurs with other SOFA components through methods such as `buildConstraintMatrix`, which constructs the matrix representing the constraint, and `getConstraintViolation` and `getConstraintResolution`, which compute how constraints are violated or resolved. This ensures that points in a model remain fixed according to user-specified parameters.\n\nThe component supports various data types including vectors of different sizes (1D, 2D, 3D, 6D) and rigid body types (`Rigid3Types`). It includes a boolean parameter `fixAll` which, if set to true, fixes all points in the model. The constraint can be applied selectively using indices as well.\n\nUsage of this component involves setting up the mechanical state where constraints are needed and configuring parameters such as `d_indices`, which specifies which points to fix. If `fixAll` is enabled, all points will be fixed without needing to specify individual indices."
  },
  "maths": {
    "maths": "# Mathematical and Physical Description of FixedLagrangianConstraint\n\n## Overview\nThe `FixedLagrangianConstraint` is a component within the Simulation Open Framework Architecture (SOFA) framework that enforces constraints on Degrees of Freedom (DOFs) in mechanical models. This constraint ensures that specified points or all points in the model remain fixed according to Lagrangian mechanics principles.\n\n## Mathematical Formulation\n### Constraint Matrix Construction\nThe `FixedLagrangianConstraint` uses a matrix representation for its constraints, denoted as \\( \textbf{C} \\). Each row of this matrix corresponds to an individual constraint equation. For a given set of points (DOFs) to be fixed:\n\n1. **For all points** (`fixAll = true`): The constraint matrix is constructed such that it spans the entire domain of DOFs in the model, effectively fixing each point.\n2. **Selective Points**: If specific indices are provided through `d_indices`, only those corresponding rows in the matrix will be active to enforce constraints on those particular points.\n\n### Constraint Equations\nThe constraint equations can be written as:\n\\[ \textbf{C} \\cdot \\mathbf{x} = 0 \\]\nwhere \\( \\mathbf{x} \\) is the vector of DOFs (positions and orientations). Each row in \\( \textbf{C} \\) corresponds to a specific constraint equation enforcing that certain components of \\( \\mathbf{x} \\) remain fixed.\n\n### Constraint Matrix Construction Example for Different Data Types:\n- **Vec1Types**: Constraints are applied on 1D DOFs (e.g., scalar positions).\n\\[ \textbf{C}_{\text{Vec1}} = [1] \\]\n- **Vec2Types**: Constraints are applied on 2D DOFs.\n\\[ \textbf{C}_{\text{Vec2}} = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix} \\]\n- **Vec3Types**: Constraints are applied on 3D positions.\n\\[ \textbf{C}_{\text{Vec3}} = \\begin{bmatrix} 1 & 0 & 0 \\\\ 0 & 1 & 0 \\\\ 0 & 0 & 1 \\end{bmatrix} \\]\n- **Vec6Types**: Constraints are applied on 6D DOFs (e.g., positions and orientations).\n\\[ \textbf{C}_{\text{Vec6}} = \\begin{bmatrix}\n1 & 0 & 0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 1 & 0 & 0 & 0 \\\\\n0 & 0 & 0 & 1 & 0 & 0 \\\\\n0 & 0 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 0 & 0 & 1\n\\end{bmatrix} \\]\n- **Rigid3Types**: Constraints are applied on rigid body positions and orientations.\n\\[ \\textbf{x}_{\text{rigid}} = [x, y, z, \\theta_x, \\theta_y, \\theta_z]^T \\]\n\\[ \textbf{C}_{\text{Rigid3}} = \\begin{bmatrix}\n1 & 0 & 0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 1 & 0 & 0 & 0 \\\\\n0 & 0 & 0 & 1 & 0 & 0 \\\\\n0 & 0 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 0 & 0 & 1\n\\end{bmatrix} \\]\n\n### Constraint Violation and Resolution\nThe `getConstraintViolation` method computes the violation of constraints, which is the difference between the current state and the fixed state. This can be represented as:\n\\[ \textbf{v}_{\text{viol}} = \textbf{C} \times (\textbf{x}_{\text{current}} - \\textbf{x}_{\text{fixed}}) \\]\nwhere \\( \textbf{x}_{\text{current}} \\) is the current configuration and \\( \\textbf{x}_{\text{fixed}} \\) is the fixed configuration.\n\nThe `getConstraintResolution` method ensures that any violation of these constraints is resolved by applying appropriate forces or impulses to enforce the constraints. This typically involves solving a system of linear equations derived from the constraint matrix \\( \textbf{C} \\).\n\n## Physical Interpretation\nIn physical terms, this constraint acts as an idealized force field that prevents specified points in the model from moving beyond their initial positions (or orientations). When applied to mechanical systems such as deformable bodies or rigid bodies, it ensures that certain parts of these systems remain stationary during simulation.\n\nBy fixing specific DOFs, the `FixedLagrangianConstraint` can simulate scenarios where parts of a system are held in place by external supports or constraints, providing more realistic and controllable simulations."
  },
  "summary": {
    "abstract": "The `FixedLagrangianConstraint` enforces Lagrangian-based constraints on specified Degrees of Freedom (DOFs) in a SOFA simulation, fixing either selected or all points according to user-defined parameters.",
    "sheet": "# FixedLagrangianConstraint\n\n## Overview\nThe `FixedLagrangianConstraint` is part of the SOFA framework and enforces Lagrangian-based constraints on specified Degrees of Freedom (DOFs) in a mechanical model. It inherits from the more general `LagrangianConstraint`, indicating its role within the constraint hierarchy for mechanical systems.\n\n## Mathematical Model\nThe component uses a matrix representation for its constraints, denoted as \\(\\mathbf{C}\\). Each row of this matrix corresponds to an individual constraint equation:\n- **For all points** (`fixAll = true`): The constraint matrix spans the entire domain of DOFs in the model.\n- **Selective Points**: If specific indices are provided through `d_indices`, only those corresponding rows in the matrix will be active to enforce constraints on those particular points.\n\nThe constraint equations can be written as:\n\\[ \\mathbf{C} \\cdot \\mathbf{x} = 0 \\]\nwhere \\(\\mathbf{x}\\) is the vector of DOFs (positions and orientations). Each row in \\(\\mathbf{C}\\) corresponds to a specific constraint equation enforcing that certain components of \\(\\mathbf{x}\\) remain fixed.\n\n### Constraint Matrix Construction Example for Different Data Types:\n- **Vec1Types**: Constraints are applied on 1D DOFs (e.g., scalar positions).\n\\[ \\mathbf{C}_{\\text{Vec1}} = [1] \\]\n- **Vec2Types**: Constraints are applied on 2D DOFs.\n\\[ \\mathbf{C}_{\\text{Vec2}} = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix} \\]\n- **Vec3Types**: Constraints are applied on 3D positions.\n\\[ \\mathbf{C}_{\\text{Vec3}} = \\begin{bmatrix} 1 & 0 & 0 \\\\ 0 & 1 & 0 \\\\ 0 & 0 & 1 \\end{bmatrix} \\]\n- **Vec6Types**: Constraints are applied on 6D DOFs (e.g., positions and orientations).\n\\[ \\mathbf{C}_{\\text{Vec6}} = \\begin{bmatrix}\n1 & 0 & 0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 1 & 0 & 0 & 0 \\\\\n0 & 0 & 0 & 1 & 0 & 0 \\\\\n0 & 0 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 0 & 0 & 1\n\\end{bmatrix} \\]\n- **Rigid3Types**: Constraints are applied on rigid body positions and orientations.\n\\[ \\mathbf{x}_{\\text{rigid}} = [x, y, z, \\theta_x, \\theta_y, \\theta_z]^T \\]\n\\[ \\mathbf{C}_{\\text{Rigid3}} = \\begin{bmatrix}\n1 & 0 & 0 & 0 & 0 & 0 \\\\\n0 & 1 & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 1 & 0 & 0 & 0 \\\\\n0 & 0 & 0 & 1 & 0 & 0 \\\\\n0 & 0 & 0 & 0 & 1 & 0 \\\\\n0 & 0 & 0 & 0 & 0 & 1\n\\end{bmatrix} \\]\n\n### Constraint Violation and Resolution\nThe `getConstraintViolation` method computes the violation of constraints, which is the difference between the current state and the fixed state. This can be represented as:\n\\[ \\mathbf{v}_{\\text{viol}} = \\mathbf{C} \\times (\\mathbf{x}_{\\text{current}} - \\mathbf{x}_{\\text{fixed}}) \\]\nwhere \\(\\mathbf{x}_{\\text{current}}\\) is the current configuration and \\(\\mathbf{x}_{\\text{fixed}}\\) is the fixed configuration.\nThe `getConstraintResolution` method ensures that any violation of these constraints is resolved by applying appropriate forces or impulses to enforce the constraints. This typically involves solving a system of linear equations derived from the constraint matrix \\(\\mathbf{C}\\).\n\n## Parameters and Data\n- **fixAll**: If true, fix all points in the model.\n  - Type: `bool`\n  - Default: Not specified (depends on configuration)\n"
  }
}