SOFA API  ca70b0f0 Open source framework for multi-physics simuation
sofa::geometry::Edge Struct Reference

`#include <Edge.h>`

## Static Public Attributes

static constexpr sofa::Size NumberOfNodes = 2

static constexpr ElementType Element_type = ElementType::EDGE

Edge ()=delete

## Static Public Member Functions

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr auto squaredLength (const Node &n0, const Node &n1)
Compute the squared length (or norm) of an edge. More...

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr auto length (const Node &n0, const Node &n1)
Compute the length (or norm) of an edge. More...

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr auto getBarycentricCoordinates (const Node &point, const Node &n0, const Node &n1)
Compute the barycentric coordinates of input point on Edge (n0, n1). It can be interpreted as masses placed at the Edge vertices such that the point is the center of mass of these masses. No check is done if point is on Edge. Method. More...

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr bool isPointOnEdge (const Node &p0, const Node &n0, const Node &n1)
Test if a point is on Edge (n0, n1) More...

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr bool intersectionWithPlane (const Node &n0, const Node &n1, const sofa::type::Vec< 3, T > &planeP0, const sofa::type::Vec< 3, T > &normal, sofa::type::Vec< 3, T > &intersection)
Compute the intersection between a plane (defined by a point and a normal) and the Edge (n0, n1) More...

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
static constexpr bool intersectionWithEdge (const Node &pA, const Node &pB, const Node &pC, const Node &pD, sofa::type::Vec< 2, T > &intersectionBaryCoord)
Compute the intersection coordinate of the 2 input edges. More...

## ◆ Element_type

 constexpr ElementType sofa::geometry::Edge::Element_type = ElementType::EDGE
staticconstexpr

## ◆ NumberOfNodes

 constexpr sofa::Size sofa::geometry::Edge::NumberOfNodes = 2
staticconstexpr

## ◆ Edge()

 sofa::geometry::Edge::Edge ( )
delete

## ◆ getBarycentricCoordinates()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr auto sofa::geometry::Edge::getBarycentricCoordinates ( const Node & point, const Node & n0, const Node & n1 )
inlinestaticconstexpr

Compute the barycentric coordinates of input point on Edge (n0, n1). It can be interpreted as masses placed at the Edge vertices such that the point is the center of mass of these masses. No check is done if point is on Edge. Method.

isPointOnEdge can be used before to check that.
Template Parameters
 Node iterable container T scalar
Parameters
 point position of the point to compute the coefficients n0,n1 nodes of the edge
Returns
sofa::type::Vec<2, T> barycentric coefficients of each vertex of the Edge.

## ◆ intersectionWithEdge()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr bool sofa::geometry::Edge::intersectionWithEdge ( const Node & pA, const Node & pB, const Node & pC, const Node & pD, sofa::type::Vec< 2, T > & intersectionBaryCoord )
inlinestaticconstexpr

Compute the intersection coordinate of the 2 input edges.

Template Parameters
 Node iterable container T scalar
Parameters
 pA,pB nodes of the first edge pC,pD nodes of the second edge intersectionBaryCoord barycentric coordinates of the intersection point expressed as alpa * pA + beta * pB if there is an intersection , node will be filled if there is an intersection otherwise will return [0, 0]
Returns
bool true if there is an intersection, otherwise false

## ◆ intersectionWithPlane()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr bool sofa::geometry::Edge::intersectionWithPlane ( const Node & n0, const Node & n1, const sofa::type::Vec< 3, T > & planeP0, const sofa::type::Vec< 3, T > & normal, sofa::type::Vec< 3, T > & intersection )
inlinestaticconstexpr

Compute the intersection between a plane (defined by a point and a normal) and the Edge (n0, n1)

Template Parameters
 Node iterable container T scalar
Parameters
 n0,n1 nodes of the edge planeP0,normal position and normal defining the plan intersection position of the intersection (if one) between the plane and the Edge
Returns
bool true if there is an intersection, otherwise false

## ◆ isPointOnEdge()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr bool sofa::geometry::Edge::isPointOnEdge ( const Node & p0, const Node & n0, const Node & n1 )
inlinestaticconstexpr

Test if a point is on Edge (n0, n1)

Template Parameters
 Node iterable container T scalar
Parameters
 p0 position of the point to test n0,n1 nodes of the edge
Returns
bool result if point is on Edge.

## ◆ length()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr auto sofa::geometry::Edge::length ( const Node & n0, const Node & n1 )
inlinestaticconstexpr

Compute the length (or norm) of an edge.

Remarks
Depending of the type of Node, it will either use a optimized version or a generic one
Optimizations are enabled for sofa::type::Vec
Template Parameters
 Node iterable container (or sofa::type::Vec for squaredLength()) T scalar
Parameters
 n0,n1 nodes of the edge
Returns
Length of the edge (a T scalar)

## ◆ squaredLength()

template<typename Node , typename T = std::decay_t<decltype(*std::begin(std::declval<Node>()))>, typename = std::enable_if_t<std::is_scalar_v<T>>>
 static constexpr auto sofa::geometry::Edge::squaredLength ( const Node & n0, const Node & n1 )
inlinestaticconstexpr

Compute the squared length (or norm) of an edge.

Remarks
Depending of the type of Node, it will either use a optimized version or a generic one
Optimizations are enabled for sofa::type::Vec
Template Parameters
 Node iterable container (or sofa::type::Vec for operator- and norm2()) T scalar
Parameters
 n0,n1 nodes of the edge
Returns
Squared length of the edge (a T scalar)