egttools.plotting.helpers.xy_to_barycentric_coordinates

xy_to_barycentric_coordinates(x, y, corners)[source]

Transforms cartesian into barycentric coordinates.

Parameters
  • x (Union[float, numpy.ndarray]) – first component of the cartesian coordinates

  • y (Union[float, numpy.ndarray]) – second component of the cartesian coordinates

  • corners (numpy.ndarray) – a list or a vector containing the coordinates of the corners

Returns

The transformmation of the coordinates into barycentric.

Return type

numpy.ndarray

Examples

>>> from egttools.plotting import Simplex2D
>>> simplex = Simplex2D()
>>> cartesian_coords = np.array([0.2, 0.])
>>> xy_to_barycentric_coordinates(cartesian_coords[0], cartesian_coords[1], simplex.corners)
array([0.2, 0. ])