5#include "mapping_tools.hpp"
20template <
class X,
class Y,
class Corner1Tag,
class Corner2Tag,
class Corner3Tag>
25 using CoordResult = ddc::Coordinate<Corner1Tag, Corner2Tag, Corner3Tag>;
35 CartesianCoord m_corner1;
36 CartesianCoord m_corner2;
37 CartesianCoord m_corner3;
48 CartesianCoord
const& corner1,
49 CartesianCoord
const& corner2,
50 CartesianCoord
const& corner3)
95 const double x = ddc::get<X>(pos);
96 const double y = ddc::get<Y>(pos);
97 const double x1 = ddc::get<X>(m_corner1);
98 const double x2 = ddc::get<X>(m_corner2);
99 const double x3 = ddc::get<X>(m_corner3);
100 const double y1 = ddc::get<Y>(m_corner1);
101 const double y2 = ddc::get<Y>(m_corner2);
102 const double y3 = ddc::get<Y>(m_corner3);
104 const double div = ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3));
105 const double lam1 = ((y2 - y3) * (x - x3) + (x3 - x2) * (y - y3)) / div;
106 const double lam2 = ((y - y3) * (x1 - x3) + (x3 - x) * (y1 - y3)) / div;
107 const double lam3 = 1 - lam1 - lam2;
108 return BarycentricCoord(lam1, lam2, lam3);
A class to convert cartesian coordinates to barycentric coordinates on a triangle.
Definition cartesian_to_barycentric.hpp:22
~CartesianToBarycentric()=default
The destructor of the mapping operator.
CartesianToBarycentric(CartesianToBarycentric &&x)=default
A r-value copy operator for the mapping operator.
KOKKOS_FUNCTION CoordResult operator()(CoordArg const &pos) const
The operator to get the equivalent barycentric coordinate of the cartesian coordinate.
Definition cartesian_to_barycentric.hpp:93
ddc::Coordinate< Corner1Tag, Corner2Tag, Corner3Tag > CoordResult
The type of a coordinate in the barycentric coordinate system.
Definition cartesian_to_barycentric.hpp:25
CartesianToBarycentric(CartesianCoord const &corner1, CartesianCoord const &corner2, CartesianCoord const &corner3)
Construct the operator which converts between the coordinate systems.
Definition cartesian_to_barycentric.hpp:47
ddc::Coordinate< X, Y > CoordArg
The type of a coordinate in the cartesian coordinate system.
Definition cartesian_to_barycentric.hpp:28
CartesianToBarycentric & operator=(CartesianToBarycentric &&x)=default
A r-value copy operator for the mapping operator.
CartesianToBarycentric & operator=(CartesianToBarycentric const &x)=default
A copy operator for the mapping operator.
CartesianToBarycentric(CartesianToBarycentric const &other)=default
A copy operator for the mapping operator.