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
 

Public Member Functions

 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...
 

Attribute details

◆ Element_type

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

◆ NumberOfNodes

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

Constructor details

◆ Edge()

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

Function details

◆ 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.

See also
isPointOnEdge can be used before to check that.
Template Parameters
Nodeiterable container
Tscalar
Parameters
pointposition of the point to compute the coefficients
n0,n1nodes 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
Nodeiterable container
Tscalar
Parameters
pA,pBnodes of the first edge
pC,pDnodes of the second edge
intersectionBaryCoordbarycentric 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
Nodeiterable container
Tscalar
Parameters
n0,n1nodes of the edge
planeP0,normalposition and normal defining the plan
intersectionposition 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
Nodeiterable container
Tscalar
Parameters
p0position of the point to test
n0,n1nodes 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
Nodeiterable container (or sofa::type::Vec for squaredLength())
Tscalar
Parameters
n0,n1nodes 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
Nodeiterable container (or sofa::type::Vec for operator- and norm2())
Tscalar
Parameters
n0,n1nodes of the edge
Returns
Squared length of the edge (a T scalar)