**2. Preliminaries**

In this paper, as usual, Z<sup>3</sup> denotes the cubic grid, whose points are addressed by integer triplets, according to the three coordinates *x*, *y*, *z.*

In order to create a continuous coordinate system for the triangular grid that enables us to uniquely address any point of the triangular grid, we combine discrete triangular coordinate systems from Reference [22] (see also Figure 1 for some examples) with the barycentric coordinate system (BCS), discovered by Möbius (see References [1,23]).

In Figure 2, a coordinate system for the tri-hexagonal grid (the three-plane triangular grid of regions [16]) and its dual is given. This grid resembles a mix of the triangular and hexagonal grids since it is a combination of the one-plane and two-plane grids [7,22]. The new coordinate system will be an extension of the discrete triangular and hexagonal coordinate systems.

**Figure 2.** Representation of the tri-hexagonal coordinate system (**a**) and its dual (**b**). The same coordinate system is used to address the pixels (**a**) and the nodes of the dual grid (**b**).

Next, a brief description is given for the discrete triangular coordinate system and BCS.

#### *2.1. Discrete Triangular Coordinate System*

The discrete Hexagonal Coordinate System uses 0-sum triplets (Figure 1a,b). The discrete Triangular Coordinate System [22] is a symmetric coordinate system that addresses each pixel by an integer triplet. The three coordinate axes have angles of 120◦ as in the hexagonal grid. The sum of the triplets is equal to 0 or 1, which refers to the two types of orientations of triangles (, ). The triangles with zero-sum are the "even" triangles (), and the triangles with one-sum triplets are the "odd" triangles () (see Figure 1).

For finding an appropriate extension to this system that is able to address all points of the 2D plane, we start by addressing the midpoints of triangles with integer triplets of +1 and −1 sum. Therefore, we call them "positive " and "negative " triangles, respectively. According to Figure 3, the coordinate system of Figure 2b is used to address midpoints of triangles of the triangular grid. Observe that each triplet assigned to a midpoint (see the blue triplets in Figure 3) builds up from the coordinate values shared by two of the corners of the given pixel (see the three red triplets around each blue triplet). There is already an important difference between our proposed and Her's zero-sum coordinate system, which includes the use of zero-sum triplets to address these midpoints as well (actually, three fractional values for each midpoint), which was a very good and efficient choice to extend the coordinate system of the hexagonal grid. However, it does not meet our requirements. Therefore, we have fixed these coordinate values in another way. We should also mention that Her's system inside the regular triangles can be seen as an application of the barycentric coordinate system (see next subsection) based on the values assigned to the corners of the triangle.

**Figure 3.** The coordinate system for the tri-hexagonal grid is used for the triangular grid (and for its dual at the same time).

#### *2.2. The Barycentric Coordinate System (BCS)*

One of the main motivations of the barycentric technique is to use a coordinate system only for a finite (bordered) segmen<sup>t</sup> of the plane, which is also more "balanced" inside this region than the values of the Cartesian frame.

The barycentric technique uses coordinate triplets to address any points inside (and on the border) of a given triangle. We put three one-sum weights, ( *w*, *v*, *u*), to the corners known as *a*, *b*, and *c* of the triangle and the mass center *p* inside the triangle is assigned to the triplet of weights. It is also known that, if the area of the triangle *abc* is one unit, then the areas of *bcp*, *acp*, and *abp* are exactly *w*, *v,* and *u*, respectively. The coordinates of *p* can be computed from the coordinates of the corners of the triangle by weighted average, i.e., *p* = *wa* + *vb* + *uc* (where *p*, *a*, *b*, and *c* are the vectors representing the positions of these points).

This formula can easily be transformed to the following formula using the fact that *w* = 1 − *v* − *u:*

$$p = a + \upsilon \left( b - a \right) + \mu \left( c - a \right) \tag{1}$$

Actually, since the three barycentric coordinate values ( *w*, *v*, and *u)* of point *p* are not independent (sum of 1), we may use only two of them, *v* and *u*, to address point *p* similarly as in an oblique coordinate system. One may understand Equation (1) as stating that the starting point is *a*, and we can go to the direction of *b* and the direction of *c* by some distance, which is indicated by *v* and *u,* respectively. However, in our approach, the starting point *a* is the midpoint of the regular triangle and, according to the values of *v* and *u*, the coordinate triplet for point *p* is calculated (see Figure 4 and Example 1).

**Figure 4.** A composition of the barycentric technique and discrete coordinate system to address points *p* and *q* in the triangular plane by coordinate triplets in (**a**) and (**b**), respectively.

In the classical barycentric technique, the point is considered to be inside a triangle, as long as the sum of (*u* and *v*) is between 0 and 1: 0 < *u* + *v* < 1. If the sum is equal to 1, then the point will be on the edge (*cb*), while it will be out of the triangle if the sum is less than 0 or greater than 1 (see Figure 4a). Now, we relax the condition of the barycentric technique and allow the sum of *u* and *v* to be any real number between 0 and 2 besides the conditions 0 ≤ *u* ≤ 1 and 0 ≤ *v* ≤ 1 hold (see Figure 4b). In this way, we may also address some points outside of the triangle. In Figure 4 and Example 1, a composition of the barycentric technique and the discrete coordinate system (assigned to the corners of an isosceles triangle in the regular triangle) is given to address other points of the plane.

**Example 1.** *Consider the triangle defined by corners (1, 0, 0), (1, 0,* −*1), and (1,* −*1, 0), which represent the three vertices a, b, and c, respectively. Let u = 0.2 and v = 0.4, where 0 < u + v < 1. Then, based on Equation (1), the coordinate triplet of point p is (1,* −*0.2,* −*0.4). If u = 0.8 and v = 0.4 (0 < u + v < 2), then the coordinate triplet of point q is (1,* −*0.8,* −*0.4) (see Figure 4).*

#### **3. Continuous Coordinate System for Reflecting the Triangular Symmetry**

In order to create a continuous triangular coordinate system that works efficiently, we combine the discrete coordinate system for the triangle grid with BCS. In the discrete triangular coordinate system, integer coordinate triplets with various sums were used. In BCS, coordinate triplets with fractional values address the points inside a triangle. We develop a new system, which uses triplets on the entire plane. We start by dividing each equilateral triangle of the triangular grid into three isosceles obtuse-angled triangles, which will possess areas A, B, and C, as shown in Figure 5. In this case, the midpoint *m* between areas will be the start point (the red point), which is represented by the letter *a* in Equation (1). This point will be used to calculate the coordinates of the points in the three areas A, B, and C.

**Figure 5.** Dividing positive (**a**) and negative (**b**) triangles to three areas A, B, and C. The letters assigned to the isosceles triangles are based on the orientation of the sides.

As we have already mentioned above, we use coordinate triplets with sum +1 and −1 for these midpoints, depending on the orientation of the original triangle. The sum of 1 represents the midpoint of the positive triangles and the sum of −1 represents the midpoint of negative triangles . Therefore, using the barycentric Equation (1) based on these midpoints, we obtain a unique triplet for each point in each area of the plane, which we will describe below.

Based on the barycentric Equation (1), we know that the values *u* and *v* are limited by 0 ≤ *u* + *v* ≤ 1 (inside or on the border of the given triangle), which gives the ability to address the points inside areas A, B, and C of each type of triangle (, ), separately. However, let us consider the case in which the sum of *u* and *v* satisfies 0 ≤ *u* + *v* ≤ 2, such that the conditions 0 ≤ *u* ≤ 1 and 0 ≤ *v* ≤ 1 hold. Then, consequently, each midpoint can be used to address not only the points in the area located in this original triangle but also the points in the neighboring area denoted with the same letters. To illustrate this, the green area in Figure 6a can be completely addressed by using either midpoint *a*(+) or *a*(−) as the starting point in Equation (1).

**Figure 6.** (**a**) By using either *a*(+) or *a*(−), the whole green area A could be addressed. (**b**) The hexagon surrounded by the thick dark blue line shows the entire area that can be addressed by using a positive midpoint *m*.

**Proposition 1.** *To address the points inside a rhombus A, B, or C, the coordinate triplet of a point does not depend on the choice of whether the midpoint of the positive or the negative triangle is used for addressing.*

**Proof.** Assume point (*p*) in area A of the negative triangle. Let *a*(+) = (*<sup>a</sup>*1, *a*2, *a*3), *a*(−) = (*<sup>a</sup>*1, *a*2 − 1, *a*3 − 1), *p* = (*p*1, *p*2, *p*3), *b* = (*b*1, *b*2, *b*3), and *c* = (*<sup>c</sup>*1, *c*2, *c*3) where *a*(+) is the midpoint of the positive triangle and *a*(−) is the midpoint of the negative one (see Figure 7).

**Figure 7.** Proving how point *p* can be calculated by either the positive or negative midpoint (*a*(+) or *a*(−)). (**a**) Shows the position of point *p* with respect to both a positive and a negative triangle, while (**b**) and (**c**) represent the calculation of the coordinates of point *p* based on the positive and negative triangles, respectively.

As we mentioned earlier, each triplet assigned to a midpoint builds up from the coordinate values shared by two of the corners of the given pixel (see Section 2.1). Thus, we have some equalities.

In the positive triangle, we have:

$$a\_1 = b\_1 = c\_1, \; b\_2 = a\_2, \; c\_3 = a\_3 \text{ and } c\_2 = a\_2 - 1, \; c\_3$$

In the negative triangle, we have:

$$a\_1 = b\_1 = c\_1, b\_2 = a\_2, c\_3 = a\_3 \text{ and } b\_2 = a\_2 - 1.$$

Now, to compute the first coordinate value, *a*1, from the positive triangle, we have the following.

$$p\_{1(+)} = a\_1 + \upsilon \begin{pmatrix} b\_1 \ -a\_1 \end{pmatrix} + \mu \begin{pmatrix} c\_1 \ -a\_1 \end{pmatrix} \text{ since } a\_1 = b\_1 = c\_1 \text{ then } p\_{1(+)} = a\_1.$$

From the negative side, we have the following.

$$p\_{1(-)} = a\_1 + (1 - v) \left(b\_1 - a\_1\right) + (1 - u) \left(c\_1 - a\_1\right) \text{ then also } p\_{1(-)} = a\_1.$$

For the second coordinate value, *a*2, from the positive triangle, we have the following.

$$p\_{2(+)} = a\_2 + v \left(b\_2 - a\_2\right) + \mu \left(c\_2 - a\_2\right)\_{\prime\prime}$$

since *b*2 = *a*2, then:

$$p\_{2(+)} = a\_2 + \mu \left(c\_2 - a\_2\right).$$

Using *c*2 *= a*2 − 1, we ge<sup>t</sup> *p*2(+) *= a*2 − *u*.

From the negative side, we have the following.

$$p\_{2(-)} = (a\_2 - 1) + (1 - \upsilon) \left(b\_2 - (a\_2 - 1)\right) + (1 - \iota) \left(c\_2 - (a\_2 - 1)\right),$$

since *b*2 = (*<sup>a</sup>*2 − 1), it is:

$$p\_{2(-)} = (a\_2 - 1) + (1 - u) \left(c\_2 - (a\_2 - 1)\right)\_2$$

since *c*2 = *a*2, then we have *p*2(−) *= a*2 − *u*.

> Lastly, for the third coordinate value, *a*3, from the positive triangle, we have:

$$p\_{\mathfrak{P}(\ast)} = a\_{\mathfrak{P}} + \upsilon \left(b\_{\mathfrak{P}} - a\_{\mathfrak{P}}\right) + \mu \left(c\_{\mathfrak{P}} - a\_{\mathfrak{P}}\right).$$

Since *c3 = a3*,

$$p\_{3(+)} = a\_3 + v \ (b\_3 - a\_3).$$

Furthermore, *b*3 *= a*3 – 1, which yields to *p*3(+) *= a*3 − *v*. From the negative side, we have the following.

$$p\_{\mathfrak{H}(-)} = (a\_{\mathfrak{H}} - 1) + (1 - \upsilon) \left(b\_{\mathfrak{H}} - (a\_{\mathfrak{H}} - 1)\right) + (1 - \iota) \left(c\_{\mathfrak{H}} - (a\_{\mathfrak{H}} - 1)\right).$$

Since *c*3 = *a*3 − 1 and *b*3 = *a*3, it can be written as:

$$(p\_{3(-)} = (a\_3 - 1) + (1 - \upsilon) \ (b\_3 - (a\_3 - 1)) = a\_3 - \upsilon.)$$

Having the point inside other regions, the proof goes in a similar manner. -

As we have already mentioned, a popular way to understand BCS for a point (inside a triangle) goes by the ratio of the areas defined by the triangles determined by the point and two of the triangle corners. In fact, our system uses a similar technique to address the points inside a triangle since it is stated in the next corollary based on the previous proposition.

**Corollary** *1. Let p be any point inside or on the border of an obtuse-angled triangle determined by a midpoint a* = (*<sup>a</sup>*1, *a*2, *<sup>a</sup>*3)*, and corners b* = (*b*1, *b*2, *b*3)*, c* = (*<sup>c</sup>*1, *c*2, c3)*. Let the barycentric coordinates of p be* (*<sup>w</sup>*, *v*, *u*), *with w* + *v* + *u* = 1, *i.e., by assigning these weights to a and b and c, respectively, the weighted midpoint is at p. Then, the coordinates of p* = (*p*1, *p*2, *p*3) *are exactly pi* = *w ai* + *v bi* + *u ci for i* = 1, 2, 3.

Notice that the three points *a*, *b,* and *c* above must have a fixed coordinate value (depending on the type of the triangle). The weighted average of this coordinate value will be the same for any point inside or on the border of this obtuse-angled triangle.

As we have seen a given triplet of corners, including a midpoint can be used to address points not only on the inside but also on the border of the triangle determined by them. The type of these regions is important in this issue. In Figure 6b, the thick, dark blue line shows the entire area that the positive midpoint can address. The key issue is to use triplets of the discrete coordinate system and to use only two barycentric fractional values inside, by using the directions of the sides of the appropriate rhombus in which the point is located. The sides of a rhombus are actually parallel to two of the coordinate axes.

Hereafter, for simplicity, we will use only the positive midpoints for further calculations, while ignoring the negative ones. The triangular plane can be seen in Figure 8a.

**Figure 8.** (**a**) Re-structuring the triangular plane to fit the Cartesian plane. (**b**) The two distinguished rectangles of the plane.

In the next two subsections, we will illustrate the conversion between the continuous coordinate system to/from the Cartesian coordinate system. Namely, we can convert the coordinate triplet of a certain point in our new coordinate system to its corresponding Cartesian coordinates and vice versa.

#### *3.1. Converting Triplets to Cartesian Coordinates*

Assume that we use (*i, j, k*) as a coordinate triplet of a point, where *I*, *J*, and *K* are the axes of the triangular plane (see Figure 1), and suppose (*x, y*) is used to indicate the same point in the Cartesian plane where *X* and *Y* are the axes.

For the conversion, we fix the side-length of the triangle of the triangular grid to √3. Consequently, its height is 1.5 (see the dashed blue lines in Figure 9). Then, the following matrix equation computes the corresponding coordinate values *x* and *y* for the given triplet (*i*, *j*, *k*):

$$
\begin{pmatrix}
\frac{\sqrt{3}}{2} & 0 & -\frac{\sqrt{3}}{2} \\
\frac{1}{2} & -1 & \frac{1}{2}
\end{pmatrix}
\cdot
\begin{pmatrix}
i \\ j \\ k
\end{pmatrix} = \frac{1}{2} \cdot \begin{pmatrix}
\sqrt{3}(i-k) \\
i - 2j + k
\end{pmatrix} = \begin{pmatrix}
x \\ y
\end{pmatrix}
\tag{2}
$$

**Figure 9.** The dashed red lines indicate the Cartesian coordinates of the point.

**Example 2.** *Let (1,* −*0.2,* −*0.5) be a point in the triangular plane. Then, based on (2):*

$$
\begin{pmatrix}
\frac{\sqrt{3}}{2} & 0 & -\frac{\sqrt{3}}{2} \\
\frac{1}{2} & -1 & \frac{1}{2}
\end{pmatrix}
\cdot
\begin{pmatrix}
1 \\
\end{pmatrix}
\approx \begin{pmatrix}
1.3 \\
0.45
\end{pmatrix}
$$

*Thus, (x, y)* ≈ *(1.3, 0.45), as shown in Figure 9.*

#### *3.2. Converting Cartesian Coordinates to Equivalent Triplets*

One of the simplest ways to do such a conversion is to determine the midpoint and the two corner points, which defines the triangle in which the given point locates (inside or on the border). Then, by computing the barycentric coordinates (weights) of the point with respect to these triangle corners, by Corollary 1, the continuous coordinate triplet is computed. In this subsection, we present a slightly different method with little more details to convert Cartesian coordinates to continuous triangular coordinates.

As we already mentioned earlier, the midpoints of positive triangles are used to address all points in the triangular plane. Therefore, every positive midpoint will address areas A, B, and C in neighbor (negative) triangles, as already seen in Figure 6b. Consequently, the triangular plane will be re-structured, which can be seen in Figure 8a. However, two kinds of rectangles can be clearly distinguished in this plane, called CB and AB (see Figure 8b).

We may start by specifying the area (i.e., rhombus) A, B, or C that a Cartesian point (*<sup>x</sup>*, *y*) belongs to. Then, we can use appropriate formulae that are assigned to each type of area, which is a process we will describe later in this section (see Table 1). Hence, the following three steps are used to specify the area.


**Table 1.** The coordinate triplets formulae, based on area type, where ... is a rounding operation \*.


\* rounding operation returns the nearest integer to the real number, such that numbers exactly the same distance from two integers are rounded to the larger absolute valued one, e.g., 1.5 = 2, −1.5 = −2 and −0.4 = 0.

We show how these steps can be computed by pseudo codes. The first step is the easiest one since we can inquire whether the values of (*<sup>x</sup>*, *y*) are greater or equal to zero or not. Then, this task is completed and the involved quarter is specified (see Code 1).
