Back

Intersection

abstract
The Intersection component in SOFA detects potential collisions using bounding volumes and computes precise intersection points between two geometric entities during both broad-phase and narrow-phase collision detection.
sheet
# Intersection ## Overview The **Intersection** component is a crucial part of the collision detection system within the SOFA framework. It handles both broad-phase (using bounding volumes) and narrow-phase (precise intersection calculations) collision detection, determining if two geometric entities intersect and computing contact points when necessary. ## Mathematical Model ### Collision Detection The Intersection component operates in two phases: 1. **Broad-Phase:** - Uses bounding volume hierarchies (BVH) to quickly determine potential collisions between objects by checking for overlaps of their bounding volumes (e.g., axis-aligned bounding boxes, spheres). 2. **Narrow-Phase:* - Once potential collisions are identified in the broad-phase, the narrow-phase performs detailed intersection tests to compute precise contact points and penetration depths. ### Intersection Calculation The exact intersection calculation involves geometric operations such as line-segment intersections or ray-triangle intersections. The goal is to determine if two geometric entities intersect and, if so, where the intersections occur. ## Parameters and Data While the **Intersection** component does not have explicit data fields, it provides methods for setting and getting alarm distance ( exttt{getAlarmDistance} and exttt{setAlarmDistance}) and contact distance ( exttt{getContactDistance} and exttt{setContactDistance}). These distances are critical in defining when to trigger collision detection and how close objects need to be before detailed intersection tests are performed. ## Dependencies and Connections The **Intersection** component typically requires or exchanges data with other components such as \texttt{CollisionModel}, which provides the geometric entities for collision testing. It fits into the scene graph by being part of a larger collision detection pipeline that includes broad-phase and narrow-phase processing.
component
{
  "description": "The Intersection class in the Sofa physics engine framework is an abstract base class that serves as the foundation for intersection algorithms between different types of collision models. It provides methods to test if intersections are possible and compute intersection points between elements, which can be bounding volumes or actual geometric objects depending on the implementation.",
  "lifecycle_methods": [
    {
      "description": "Called at the beginning of the broad phase of collision detection to perform any required initialization.",
      "name": "beginBroadPhase"
    },
    {
      "description": "Invoked after the broad phase is complete, allowing for cleanup or additional processing.",
      "name": "endBroadPhase"
    },
    {
      "description": "Executed when the narrow phase begins, enabling setup specific to precise collision testing.",
      "name": "beginNarrowPhase"
    },
    {
      "description": "Called at the conclusion of the narrow phase to finalize any post-processing steps",
      "name": "endNarrowPhase"
    }
  ],
  "name": "Intersection",
  "properties": [
    {
      "description": "A pure virtual function that returns an intersector object capable of handling the given pair of collision models. This allows for determining if intersection is supported between two specific types of elements and provides access to the necessary functionality to compute intersections.",
      "name": "findIntersector",
      "type": "function"
    },
    {
      "description": "A deprecated method that checks whether an intersection test is implemented for a particular combination of element types. This function relies on findIntersector to determine support.",
      "name": "isSupported",
      "type": "function"
    },
    {
      "description": "Indicates if the intersection algorithm uses proximity detection, which determines potential intersections based on distance rather than actual overlap.",
      "name": "useProximity",
      "type": "function"
    },
    {
      "description": "Specifies whether continuous collision detection is employed. Continuous collision detection aims to detect collisions during motion, not just at discrete time steps.",
      "name": "useContinuous",
      "type": "function"
    },
    {
      "description": "Returns the type of continuous intersection handling, such as swept volumes or other techniques.",
      "name": "continuousIntersectionType",
      "type": "function"
    },
    {
      "description": "Retrieves the alarm distance used in proximity detection to alert when objects are close enough that a collision may occur soon.",
      "name": "getAlarmDistance",
      "type": "function"
    },
    {
      "description": "Sets the alarm distance threshold for proximity-based intersection tests.",
      "name": "setAlarmDistance",
      "type": "function"
    },
    {
      "description": "Returns the contact distance used to determine when objects are considered in collision or contact.",
      "name": "getContactDistance",
      "type": "function"
    },
    {
      "description": "Sets the contact distance for proximity-based intersection checks.",
      "name": "setContactDistance",
      "type": "function"
    }
  ],
  "related_classes": [
    "ElementIntersector",
    "CollisionModel"
  ],
  "usage_notes": [
    "Intersection is an abstract class and must be subclassed with concrete implementations for different intersection algorithms.",
    "The findIntersector method is critical as it connects specific collision models to their corresponding intersector objects."
  ]
}
maths
The **Intersection** component in the SOFA framework is designed to handle collision detection between two geometric entities. It operates within the broader context of computational mechanics, particularly focusing on interaction and contact resolution. Here's a detailed mathematical and physical description: ### Governing Equations or Operators Contributed - **Collision Detection:** The primary role of the Intersection component is to determine if two geometric elements (e.g., tetrahedra, triangles) intersect with each other. This involves checking for both potential collisions using bounding volumes and precise intersections by computing contact points. ### Constitutive or Kinematic Laws Involved - **Bounding Volumes:** The algorithm first checks whether the bounding volumes of the two entities overlap. If they do not, then no further detailed intersection test is performed. - **Intersection Calculation:** Once potential collision is detected (i.e., bounding volume overlap), a precise intersection calculation is conducted to find actual contact points or intersections between the elements. This step involves geometric operations such as line-segment intersection tests, ray-triangle intersections, etc. ### Role in Global FEM Pipeline - **Collision Detection Phase:** The Intersection component plays a critical role during the collision detection phase of the simulation pipeline. It ensures that interactions and contacts are accurately determined before proceeding to resolve constraints or forces due to these contacts. - **Broad/Narrow Phases:** It operates within two phases: broad-phase, where it quickly determines potential collisions using bounding volumes, and narrow-phase, where detailed intersection tests are performed to determine exact contact points and penetration depths. ### Numerical Methods or Discretization Choices Encoded - **Bounding Volume Hierarchies (BVH):** The component often uses BVH for efficient broad-phase collision detection. This method reduces the number of detailed intersection checks by first comparing bounding volumes (e.g., axis-aligned bounding boxes, spheres). - **Detailed Intersection Algorithms:** For narrow-phase detection, precise geometric algorithms are employed to compute intersections accurately. ### Integration into Variational/Lagrangian Mechanics Framework - **Constraint Handling:** While this component primarily focuses on detecting collisions and computing intersection points, the results it provides are used in subsequent steps of the simulation pipeline. Specifically, detected contacts lead to constraint forces that must be handled within the Lagrangian mechanics framework. - **Contact Forces:** The computed intersections contribute to contact forces between interacting bodies, which are then incorporated into the overall force balance and dynamic equations governing the system's motion. ### Summary The Intersection component is fundamental in ensuring accurate collision detection and contact resolution within SOFA simulations. It bridges geometric operations with the physical mechanics framework by identifying where interactions occur and facilitating their subsequent handling through constraints and forces.
{
  "name": "Intersection",
  "main": {
    "name": "Intersection",
    "namespace": "sofa::core::collision",
    "module": "Sofa.framework.Core",
    "include": "sofa/core/collision/Intersection.h",
    "doc": "Given 2 collision elements, test if an intersection is possible (for bounding volumes), or compute intersection points if any",
    "inherits": [
      "BaseObject"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "toIntersection",
        "return_type": "const Intersection *",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "findIntersector",
        "return_type": "ElementIntersector *",
        "params": [
          {
            "name": "object1",
            "type": "core::CollisionModel *"
          },
          {
            "name": "object2",
            "type": "core::CollisionModel *"
          },
          {
            "name": "swapModels",
            "type": "bool &"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": true,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "isSupported",
        "return_type": "bool",
        "params": [
          {
            "name": "elem1",
            "type": "core::CollisionElementIterator"
          },
          {
            "name": "elem2",
            "type": "core::CollisionElementIterator"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "useProximity",
        "return_type": "bool",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "useContinuous",
        "return_type": "bool",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "continuousIntersectionType",
        "return_type": "CollisionModel::ContinuousIntersectionTypeFlag",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getAlarmDistance",
        "return_type": "SReal",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getContactDistance",
        "return_type": "SReal",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setAlarmDistance",
        "return_type": "void",
        "params": [
          {
            "name": "",
            "type": "SReal"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setContactDistance",
        "return_type": "void",
        "params": [
          {
            "name": "",
            "type": "SReal"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "beginBroadPhase",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "endBroadPhase",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "beginNarrowPhase",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "endNarrowPhase",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "component": {
      "name": "Intersection",
      "description": "The Intersection class in the Sofa physics engine framework is an abstract base class that serves as the foundation for intersection algorithms between different types of collision models. It provides methods to test if intersections are possible and compute intersection points between elements, which can be bounding volumes or actual geometric objects depending on the implementation.",
      "properties": [
        {
          "name": "findIntersector",
          "type": "function",
          "description": "A pure virtual function that returns an intersector object capable of handling the given pair of collision models. This allows for determining if intersection is supported between two specific types of elements and provides access to the necessary functionality to compute intersections."
        },
        {
          "name": "isSupported",
          "type": "function",
          "description": "A deprecated method that checks whether an intersection test is implemented for a particular combination of element types. This function relies on findIntersector to determine support."
        },
        {
          "name": "useProximity",
          "type": "function",
          "description": "Indicates if the intersection algorithm uses proximity detection, which determines potential intersections based on distance rather than actual overlap."
        },
        {
          "name": "useContinuous",
          "type": "function",
          "description": "Specifies whether continuous collision detection is employed. Continuous collision detection aims to detect collisions during motion, not just at discrete time steps."
        },
        {
          "name": "continuousIntersectionType",
          "type": "function",
          "description": "Returns the type of continuous intersection handling, such as swept volumes or other techniques."
        },
        {
          "name": "getAlarmDistance",
          "type": "function",
          "description": "Retrieves the alarm distance used in proximity detection to alert when objects are close enough that a collision may occur soon."
        },
        {
          "name": "setAlarmDistance",
          "type": "function",
          "description": "Sets the alarm distance threshold for proximity-based intersection tests."
        },
        {
          "name": "getContactDistance",
          "type": "function",
          "description": "Returns the contact distance used to determine when objects are considered in collision or contact."
        },
        {
          "name": "setContactDistance",
          "type": "function",
          "description": "Sets the contact distance for proximity-based intersection checks."
        }
      ],
      "lifecycle_methods": [
        {
          "name": "beginBroadPhase",
          "description": "Called at the beginning of the broad phase of collision detection to perform any required initialization."
        },
        {
          "name": "endBroadPhase",
          "description": "Invoked after the broad phase is complete, allowing for cleanup or additional processing."
        },
        {
          "name": "beginNarrowPhase",
          "description": "Executed when the narrow phase begins, enabling setup specific to precise collision testing."
        },
        {
          "name": "endNarrowPhase",
          "description": "Called at the conclusion of the narrow phase to finalize any post-processing steps"
        }
      ],
      "usage_notes": [
        "Intersection is an abstract class and must be subclassed with concrete implementations for different intersection algorithms.",
        "The findIntersector method is critical as it connects specific collision models to their corresponding intersector objects."
      ],
      "related_classes": [
        "ElementIntersector",
        "CollisionModel"
      ]
    }
  },
  "maths": {
    "maths": "The **Intersection** component in the SOFA framework is designed to handle collision detection between two geometric entities. It operates within the broader context of computational mechanics, particularly focusing on interaction and contact resolution. Here's a detailed mathematical and physical description:\n\n### Governing Equations or Operators Contributed\n- **Collision Detection:** The primary role of the Intersection component is to determine if two geometric elements (e.g., tetrahedra, triangles) intersect with each other. This involves checking for both potential collisions using bounding volumes and precise intersections by computing contact points.\n\n### Constitutive or Kinematic Laws Involved\n- **Bounding Volumes:** The algorithm first checks whether the bounding volumes of the two entities overlap. If they do not, then no further detailed intersection test is performed.\n- **Intersection Calculation:** Once potential collision is detected (i.e., bounding volume overlap), a precise intersection calculation is conducted to find actual contact points or intersections between the elements. This step involves geometric operations such as line-segment intersection tests, ray-triangle intersections, etc.\n\n### Role in Global FEM Pipeline\n- **Collision Detection Phase:** The Intersection component plays a critical role during the collision detection phase of the simulation pipeline. It ensures that interactions and contacts are accurately determined before proceeding to resolve constraints or forces due to these contacts.\n- **Broad/Narrow Phases:** It operates within two phases: broad-phase, where it quickly determines potential collisions using bounding volumes, and narrow-phase, where detailed intersection tests are performed to determine exact contact points and penetration depths.\n\n### Numerical Methods or Discretization Choices Encoded\n- **Bounding Volume Hierarchies (BVH):** The component often uses BVH for efficient broad-phase collision detection. This method reduces the number of detailed intersection checks by first comparing bounding volumes (e.g., axis-aligned bounding boxes, spheres).\n- **Detailed Intersection Algorithms:** For narrow-phase detection, precise geometric algorithms are employed to compute intersections accurately.\n\n### Integration into Variational/Lagrangian Mechanics Framework\n- **Constraint Handling:** While this component primarily focuses on detecting collisions and computing intersection points, the results it provides are used in subsequent steps of the simulation pipeline. Specifically, detected contacts lead to constraint forces that must be handled within the Lagrangian mechanics framework.\n- **Contact Forces:** The computed intersections contribute to contact forces between interacting bodies, which are then incorporated into the overall force balance and dynamic equations governing the system's motion.\n\n### Summary\nThe Intersection component is fundamental in ensuring accurate collision detection and contact resolution within SOFA simulations. It bridges geometric operations with the physical mechanics framework by identifying where interactions occur and facilitating their subsequent handling through constraints and forces."
  },
  "summary": {
    "abstract": "The Intersection component in SOFA detects potential collisions using bounding volumes and computes precise intersection points between two geometric entities during both broad-phase and narrow-phase collision detection.",
    "sheet": "# Intersection\n\n## Overview\n\nThe **Intersection** component is a crucial part of the collision detection system within the SOFA framework. It handles both broad-phase (using bounding volumes) and narrow-phase (precise intersection calculations) collision detection, determining if two geometric entities intersect and computing contact points when necessary.\n\n## Mathematical Model\n\n### Collision Detection\n\nThe Intersection component operates in two phases:\n\n1. **Broad-Phase:**\n   - Uses bounding volume hierarchies (BVH) to quickly determine potential collisions between objects by checking for overlaps of their bounding volumes (e.g., axis-aligned bounding boxes, spheres).\n2. **Narrow-Phase:*\n   - Once potential collisions are identified in the broad-phase, the narrow-phase performs detailed intersection tests to compute precise contact points and penetration depths.\n\n### Intersection Calculation\n\nThe exact intersection calculation involves geometric operations such as line-segment intersections or ray-triangle intersections. The goal is to determine if two geometric entities intersect and, if so, where the intersections occur.\n\n## Parameters and Data\n\nWhile the **Intersection** component does not have explicit data fields, it provides methods for setting and getting alarm distance (\texttt{getAlarmDistance} and \texttt{setAlarmDistance}) and contact distance (\texttt{getContactDistance} and \texttt{setContactDistance}). These distances are critical in defining when to trigger collision detection and how close objects need to be before detailed intersection tests are performed.\n\n## Dependencies and Connections\n\nThe **Intersection** component typically requires or exchanges data with other components such as \\texttt{CollisionModel}, which provides the geometric entities for collision testing. It fits into the scene graph by being part of a larger collision detection pipeline that includes broad-phase and narrow-phase processing."
  }
}