1 Introduction

Collision detection is computationally expensive for the physical simulations of rigid bodies. In this study, we propose a fast computational method for collision detection between two rotational ellipsoids. Collision detection of ellipsoids is used in various fields, for example, robot motion generation [1]. In this method, the accuracy of collision detection is critical to safety and efficiency. Some methods use ellipsoids to approximate people, obstacles, and robots for collision avoidance [2] and path generation [3]. The discrete element method is used for particle flow and involves collision detection of a large number of ellipsoids. Fast calculations are necessary for this method. This method has been used for the structural analysis of materials [4] as well as fluids such as liquids and gases [5, 6].

Generally, ellipsoid collision detection is based on computing the sum of sets using combinatorial calculations. However, this method requires a large number of samples to achieve high accuracy and is computationally expensive. Methods [7, 8], which approximates the sum of a set of ellipsoids using the ellipsoids that are circumscribed by it, accelerate collision detection by algebraic computation, regardless of the number of samplings. However, the approximation function is an ellipsoid with a large error. The approach of approximating a set sum of ellipsoids by a curve of implicit functions does not completely describe them. In particular, when the ellipticity is small, the sum is shaped like a parallelogram. Therefore, we focused on the superellipsoid function that represents both ellipses and parallelograms by the value of the exponent. In this study, we propose an accurate and fast approximate calculation method for the sum of rotational ellipsoids by using the superellipsoid function. We compute the parameters of the superellipsoid by algebraic computation.

Fig. 1
figure 1

Minkowski sum \(\varvec{A}_{1}+\varvec{A}_{2}\) (purple area) of rotational ellipsoids \(\varvec{A}_{1}\) (red area) and \(\varvec{A}_{2}\) (blue area)

2 Related works

The set sum used for collision detection, as shown in Fig. 1, is called the Minkowski sum, which is computationally expensive because it requires the sum of all elements of the two ellipsoids as a subset. A method proposed in [9] accelerated collision avoidance simulations by obtaining the Minkowski sum of two-dimensional ellipses for each angular interval in advance. However, when considering ellipsoids, this method required the calculation of the Minkowski sums at all crossing angles in three dimensions, which is computationally expensive. Therefore, several methods approximated the Minkowski sum using an implicit function to reduce the computational complexity. The method proposed in [7, 8, 10], which approximated the Minkowski sum using an ellipsoid bounding the Minkowski sum, achieved fast collision detection; however, the approximation error was large. Similarly, an approximation with inscribed ellipsoids of Minkowski sums was also proposed [11], but the approximation error is large. Another method [12] used an affine transformation to approximate analytically.

There is also an approach to collision detection of rotational ellipsoids without approximating the Minkowski sum. A method that approximated the joints of two robots as ellipsoids and performed collision detection between the two ellipsoids [1] used a matrix calculation of the two ellipsoids to replace the positional relationship between the points and ellipsoids. A method was proposed in [13] for collision detection in which vehicles were modeled as ellipsoids considering the uncertainty. In this method, an ellipse was composed of multiple circles, and collision detection was performed accurately by the collision detection of all combinations of circles within the two ellipses. However, when the ratio of the long to short diameters was large, the number of circles approximating the ellipse increased, which subsequently increased the computational cost.

Fig. 2
figure 2

Collision detection of ellipsoids \(\varvec{A}_{1}\) and \(\varvec{A}_{2}\) (red area) by Minkowski sum \(\varvec{A}_{1}+\varvec{A}_{2}\) (blue area). Subset of ellipsoids \(\varvec{A}_2^{\prime }\) interferes with ellipse \(\varvec{A}_1\) and subset of ellipsoids \(\varvec{A}_2^{\prime \prime }\) does not interfere with ellipse \(\varvec{A}_1\)

3 Preliminaries

3.1 Minkowski sum of rotational ellipsoids

In this section, we discuss the Minkowski sums of rotational ellipsoids and their characteristics. In the collision detection of them \(\varvec{A}_1\) and \(\varvec{A}_2\) in this study, the Minkowski sum is created based on the center O of \(\varvec{A}_1\), and the collision detection of \(\varvec{A}_1\) and \(\varvec{A}_2\) is performed based on the relationship between the Minkowski sum and the center of \(\varvec{A}_2\). Considering this method with Fig. 2 as an example, if the center O\(^\prime \) of subset \(\varvec{A}_2^{\prime }\) is included in the Minkowski sum, it is judged that there is a collision. Otherwise, when the center O\(^{\prime \prime }\) of the subset \(\varvec{A}_2^{\prime \prime }\) is not included in the Minkowski sum, there is no collision. In this case, the coordinate system is arranged such that the major semi-axis of \(\varvec{A}_1\) is the X-axis, the Y-axis is the XY plane, the plane formed by the X-axis, and the major semi-axis vector is \(\varvec{A}_2\). The Z-axis is perpendicular to the XY plane. Therefore, the rotation matrices of each rotational ellipsoid are denoted by \(\varvec{U}_1 = \varvec{I} \in \mathbb {R}^{3\times 3}\) and \(\varvec{U}_2\)=[\([\textrm{cos}\theta ,-\textrm{sin}\theta ,0]\),\([\textrm{sin}\theta ,\textrm{cos}\theta ,0]\),[0, 0, 1]] \(\in \mathbb {R}^{3\times 3}\) using the angle \(\theta \) between the major semi-axis. The shape matrix \(V_i\in \ \mathbb {R}^{3\times 3}\) of the i-th rotational ellipsoid is expressed as follows by denoting \(\varvec{S}_i = \textrm{diag}\)[\(1/{\alpha _i}^2\), \(1/{\beta _i}^2\), \(1/{\beta _i}^2\)] from the semi-major and semi-minor axes \(\alpha _i\) and \(\beta _i\) of each rotational ellipsoid.

$$\begin{aligned} \varvec{V}_i = \varvec{U}_i \varvec{S}_i {\varvec{U}_i}^T \end{aligned}$$
(1)
Fig. 3
figure 3

Arrangement of rotational ellipsoids \(\varvec{A}_{1}\) and \(\varvec{A}_{2}\), and definition of XYZ coordinate system

Fig. 4
figure 4

When taking the position vectors \(\varvec{r}_{1}\) and \(\varvec{r}_{2}\) from each ellipsoid \(\varvec{A}_{1}\) and \(\varvec{A}_{2}\) from the normal vector \(\varvec{n}\), the sum of the position vectors \(\varvec{r}\) is a point on the Minkowski sum

The position vector \(\varvec{v}_i\in \ \mathbb {R}^{3\times }\) of the rotational ellipsoid is assumed to be a zero vector, because it is not considered when creating the Minkowski sum. Finally, collision detection is performed at the center O\(^\prime \) of the Minkowski sum and \(\varvec{A}_2\), considering the positional relationship. Consequently, the ellipsoid is represented by the following equation, as shown in Fig. 3:

$$\begin{aligned} q(\varvec{v}_i, \varvec{V}_i)&= \{ \varvec{x} \in \mathbb {R}^{3\times } \mid (\varvec{x} - \varvec{v}_i)^T \varvec{V}_i (\varvec{x} - \varvec{v}_i) \le 1 \} \nonumber \\&= \{ \varvec{x} \in \mathbb {R}^{3\times } \mid \varvec{x}^T \varvec{V}_i \varvec{x} \le 1 \} \end{aligned}$$
(2)

The Minkowski sum, which is a union of sets, is the set of all vector sums of points in \(\varvec{A}_1\) and \(\varvec{A}_2\), where \(\varvec{A}_1\) and \(\varvec{A}_2\) represent subsets of the three-dimensional Euclidean space \(\mathbb {R}^3\) of the two rotational ellipsoids. To make it more understandable, we first arbitrarily determine the element \(\varvec{s}_1 \in \varvec{A}_1\) of one set \(\varvec{A}_1\), and then the Minkowski sum with the other set \(\varvec{A}_2\) is expressed as follows:

$$\begin{aligned} \varvec{s}_1+\varvec{A}_2\ =\ {\varvec{s}_1+\varvec{s}_2\in \mathbb {R}^3\ |\ \varvec{s}_2\in \varvec{A}_2} \end{aligned}$$
(3)

Considering the above Minkowski sum for all elements \(\varvec{s}_1\) of \(\varvec{A}_1\), we obtain the following equation, which shows the combination of all vector sums:

$$\begin{aligned} \bigcup _{\varvec{s}_1\in \ \varvec{A}_1}{\varvec{s}_1+\varvec{A}_2}\ =\ \bigcup _{\varvec{s}_1\in \ \varvec{A}_1}{{\varvec{s}_1+\varvec{s}_2\in \mathbb {R}^3\ |\ \varvec{s}_2\in \ \varvec{A}_2}} \end{aligned}$$
(4)

It is known that a certain position vector \(\varvec{r}\), which composes the contour of the Minkowski sum of convex sets, has the same normal vector if it is the sum of position vectors \(\varvec{r}_1\) and \(\varvec{r}_2\) of the two subsets [14]. Considering Fig. 4 as an example and using the unit normal vector \(\varvec{n}\) at position vector \(\varvec{r}\), the following equation holds:

$$\begin{aligned} \varvec{r}\cdot \varvec{n}\ =\ \varvec{r}_1\cdot \varvec{n}+\varvec{r}_2\cdot \varvec{n} \end{aligned}$$
(5)

Because the outline of a rotational ellipsoid, which is differentiable among closed convex sets, has a different unit normal vector at every point, the Minkowski sum is computed using all the possible unit normal vectors in three dimensions. Collision detection between convex sets using this method [15] is accurate but computationally expensive, based on the number of sampling points.

3.2 Superellipsoid

This section describes the geometrical characteristics of the superellipsoid used for the approximation and the ease of determining whether a point is inside or outside a superellipsoid. The superellipsoid is the closed curve of the implicit function in Eq. (6) with radius parameters \(\eta _1\), \(\eta _2\), \(\eta _3\) and exponents \(\varepsilon _1\) and \(\varepsilon _2\).

$$\begin{aligned} f(x, y, z) \ =\ \left( \left| \frac{x}{\eta _1}\right| ^{\frac{2}{\varepsilon _1}}+\left| \frac{y}{\eta _2}\right| ^{\frac{2}{\varepsilon _1}}\right) ^{\frac{\varepsilon _1}{\varepsilon _2}}+\left| \frac{z}{\eta _3}\right| ^{\frac{2}{\varepsilon _2}} \end{aligned}$$
(6)
Fig. 5
figure 5

Shape of the superellipsoid depending on the exponents \(\varepsilon _1\) and \(\varepsilon _2\)

Fig. 6
figure 6

Point inclusion check in the superellipsoid (green area)

Each point (xyz) with \(f(x, y, z) = 1\) shows a surface of the superellipsoid, the shape of which varies based on the exponents \(\varepsilon _1\) and \(\varepsilon _2\), as shown in Fig. 5. In particular, it becomes ellipsoid when the exponents \(\varepsilon _1\rightarrow 1\) and \(\varepsilon _2\rightarrow 1\), and a rectangle when \(\varepsilon _1\rightarrow 0\) and \(\varepsilon _2\rightarrow 0\). When expressed in terms of mediator variables \(\varphi _1\ \in \ [0,\ 2\pi \ )\) and \(\varphi _2\ \in \ [0,\ \pi \ )\), the following equation is obtained using the sign function:

$$\begin{aligned} \begin{aligned} x&= \eta _1 \, \text {sign}\left( \textrm{sin}\varphi _1 \textrm{sin}\varphi _2\right) \left| \textrm{sin}{\varphi _1}\right| ^{\varepsilon _1} \left| \textrm{sin}{\varphi _2}\right| ^{\varepsilon _2} \\ y&= \eta _2 \, \text {sign}\left( \textrm{sin}\varphi _1 \textrm{cos}\varphi _2\right) \left| \textrm{sin}{\varphi _1}\right| ^{\varepsilon _1} \left| \textrm{cos}{\varphi _2}\right| ^{\varepsilon _2} \\ z&= \eta _3 \, \text {sign}\left( \textrm{cos}\varphi _1\right) \left| \textrm{cos}{\varphi _1}\right| ^{\varepsilon _1} \end{aligned} \end{aligned}$$
(7)

Implicit functions are characterized by the ability to easily determine whether a point is inside or outside a point. Therefore, it is easy to use collision detection method. Considering Fig. 6 as an example, in the case of the upper point (\(x_1\), \(y_1\), \(z_1\)), the equation f(\(x_1\), \(y_1\), \(z_1\)) is greater than 1, so it is determined to be outside the superellipsoid. On the contrary, in the case of the lower point (\(x_2\), \(y_2\), \(z_2\)), the equation f(\(x_2\), \(y_2\), \(z_2\)) is less than or equal to 1, so it is a point inside the superellipsoid.

4 Superellipsoidal approximation of Minkowski sum

Fig. 7
figure 7

Computing Minkowski sum in three dimensions down to the two-dimensional XY plane

In this study, we use the superellipsoid to approximate the Minkowski sum. The procedure uses the semi-major axes \(\alpha _1\), \(\alpha _2\) and the semi-minor semiaxes \(\beta _1\), \(\beta _2\) of the two rotational ellipsoids, along with the angle \(\theta \) between their major semiaxes. This process is shown in Fig. 7. First, we consider the Minkowski sum of the ellipses in the XY plane. In other words, in Eq. (6), we dealt with the following expression for the superellipse in which x and y are variables:

$$\begin{aligned} \left| \frac{x}{\eta _1}\right| ^{\frac{2}{\varepsilon _1}}+\left| \frac{y}{\eta _2}\right| ^{\frac{2}{\varepsilon _1}}\ =\ 1 \end{aligned}$$
(8)

In addition, the parametric equation Eq. (7) is in the XY plane with \(\varphi _2=\pi /2\); therefore, the following equation is used:

$$\begin{aligned} \begin{matrix} x&{}=\ \eta _1\ \text {sign}(\textrm{sin}\varphi _1)\ {|\textrm{sin}\varphi _1|}^{\varepsilon _1}\\ y&{}=\ \eta _2\ \text {sign}(\textrm{cos}\varphi _1)\ {|\textrm{cos}\varphi _1|}^{\varepsilon _1} \end{matrix} \end{aligned}$$
(9)

Subsequently, the radius parameter \(\eta _3\) in the Z-axis direction of the superellipsoid Eq. (6) and the exponential value \(\varepsilon _2\) are obtained. The detailed calculation method and the derivation of the related equations are explained below.

4.1 Approximation by superellipse in the XY plane

In the XY plane, ellipses have the same ellipticity as three-dimensional ellipsoids, simplifying the problem. In this section, the Minkowski sum of two ellipses in the XY plane is approximated by a superellipse. The procedure is to create the parallelogram shown in the left of Fig. 8, and then approximate the Minkowski sum from the parallelogram by calculating the exponent value \(\varepsilon _1\) of the superellipse as shown in the right of Fig. 8.

Fig. 8
figure 8

Procedure for approximating the Minkowski sum of two ellipses by a superellipse in the XY plane. Left: A short depth \(\delta \) parallelogram circumscribed by the Minkowski sum of two ellipses. Right: Calculating the exponent value \(\varepsilon _1\) so that the superellipse intersects a point on the Minkowski sum

Fig. 9
figure 9

Derivation of points P and Q using the normal vectors \(\varvec{n}_1\) and \(\varvec{n}_2\) to the major axis of each rotational ellipsoid

4.1.1 Parallelogram circumscribed by Minkowski sum

We must determine a parallelogram circumscribed by the Minkowski sum that has the smallest possible depth. To minimize the depth \(\delta \) as much as possible, we prepared vectors \(\varvec{n}_1\) and \(\varvec{n}_2\) perpendicular to each major semi-axis and determine points P and Q, as shown in Fig. 9, on the Minkowski sum from Eq. (5). Of the points P and Q, the component in the direction of the normal vector \(\varvec{n}_2\) of the point Q closest to the origin O is set to be half the depth \(\delta /2\) of the parallelogram. The axis in the same direction as \(\varvec{n}_2\) is axis B, and the normal direction is axis A.

Fig. 10
figure 10

Initial conditions for deriving a point on the B-axis and on the Minkowski sum with the distance function \(f\ (\xi \ )\)

Subsequently, we must determine the base \(\lambda \) of the parallelogram. The base \(\lambda \) must be a point on the Minkowski sum and on the axis B. Because this method does not directly identify a point, it is obtained through convergence calculations. First, an initial point on the Minkowski sum and close to the axis B is obtained with the normal vector \(\varvec{n}_0(\bot \) OQ), as shown in Fig. 10. Subsequently, a convergence calculation is performed using a function \(f\ (\xi \ )\) whose input is the angle \(\xi \) between the normal and X-axis, and whose output is the distance between the point obtained by \(\xi \) and the axis B, so that the convergence is within the error margin. After convergence calculation from the tangent angle \({\xi \ }_0\) of OQ, a solution \({\xi \ }_{True}\) is obtained, as shown in Fig. 11. The point R on the Minkowski sum obtained using the normal vector \(\varvec{n}_{true}\) that yields the solution \({\xi \ }_{True}\) is on the axis B, and OR is half \(\lambda /2\) of the base of the parallelogram.

Fig. 11
figure 11

Derivation of point R on the B-axis and on the Minkowski sum by convergence calculation of the distance function \(f\ (\xi \ )\)

Finally, we derive an affine transformation equation for the parallelogram using shearing. The shear matrix \(\varvec{M}^{2\times 2}\), when it is shifted along the B-axis by an angle \(\psi \) with respect to the A-axis, is expressed as follows:

$$\begin{aligned} \varvec{M}\ =\ \left[ \begin{matrix} 1&{}\textrm{tan}\psi \ \\ 0&{}1\\ \end{matrix}\right] \end{aligned}$$
(10)

Angle \(\psi \) is the tangent angle \({\xi \ }_{True}\) at point R, because the tangent line at point R is one side of the parallelogram. The original coordinates \((x_0,\ y_0)\) are transformed in to affine-transformed coordinates \(({x_0}^\prime ,\ {y_0}^\prime )\) using the following formula:

$$\begin{aligned} \left[ \begin{matrix}{x_0}^\prime \\ {y_0}^\prime \\ \end{matrix}\right] \ =\ \textbf{M}\ \left[ \begin{matrix}x_0\\ \ y_0\\ \end{matrix}\right] \end{aligned}$$
(11)

The above calculations create a parallelogram (Fig. 8, left) circumscribed by the Minkowski sum of the depth \(\delta \), base \(\lambda \), and displacement \(\psi \).

4.1.2 Derivation of exponent \(\varepsilon _1\)

The shape is determined by computing the exponent \(\varepsilon _1\), so that it intersects the superellipse at some point on the Minkowski sum. Regardless of the exponent \(\varepsilon _1\), it is determined to overlap with the superellipse at points Q and R on the Minkowski sum. Therefore, we believe that the approximation error is reduced by choosing a point on the Minkowski sum that is far from points Q and R as the intersection points. First, as shown in Fig. 12 point G\(^\prime (x_G^\prime , y_G^\prime )\) on the Minkowski sum is obtained from the normal vector \(\varvec{n}_3^\prime \) of the line connecting points Q and R. Subsequently, an inverse affine transformation is performed on point G\(^\prime \) to obtain point G\((x_G, y_G)\). The normal vector \(\varvec{n}_3\) of point G is approximated as a line perpendicular to the line connecting the two points obtained by inverse affine transformation of points Q and R. The exponent \(\varepsilon _1\) is calculated so that the superellipse overlaps the point G. The calculation method of the exponent \(\varepsilon _1\) is described below. The sign function is removed from the parametric equation of the superellipse Eq. (9) and differentiated by the mediator variable \(\varphi _1\), and the result is as follows:

$$\begin{aligned} \begin{array}{ll} \frac{{\textrm{d}}x}{{\textrm{d}}\varphi _1}\ {} &{}=\ -\ \eta _1\varepsilon _1\ \textrm{cos}\varphi _1\ \textrm{sin}^{\varepsilon _1-1}\ \varphi _1 \\ \frac{{\textrm{d}}y}{{\textrm{d}}\varphi _1}\ {} &{}=\ -\ \eta _2\varepsilon _1\ \textrm{sin}\varphi _1\ \textrm{cos}^{\varepsilon _1-1}\ \varphi _1 \\ \end{array} \end{aligned}$$
(12)
Fig. 12
figure 12

Procedure for determining the shape of the superellipse by overlapping the point G of the Minkowski sum. Top: Deriving point G\(^\prime \) from the Minkowski sum by the normal vector \(\varvec{n}_3^\prime \). Bottom: Calculating the exponent \(\varepsilon _1\) so that the inverse affine transformation of the point G\(^\prime \) overlaps the superellipse

The slope of the tangent line at point G is \(\gamma _G\) rad; however, the slope at the tangent line at point G is not \(\gamma _G\); therefore, the point G\((x_G, x_G)\) and the slope \(\gamma _G\) satisfy the approximation Eq. (13) as follows:

$$\begin{aligned} \frac{{\textrm{d}}y_G}{{\textrm{d}}x_G}\ \approx \ \textrm{tan}\gamma _G \end{aligned}$$
(13)

If we consider that the coordinates of point G are expressed in terms of the mediator variable \(\varphi _{1G}\) and the exponent \(\varepsilon _{1G}\), we obtain \(dx_G/\ d\varphi _1\) and \(dy_G/\ d\varphi _1\) from Eq. (12). Transforming Eq. (13) by \(dx_G/\ d\varphi _1\) and \(dy_G/\ d\varphi _1\) yields the following relationship:

$$\begin{aligned} \textrm{tan}\gamma _G&\approx -\frac{\eta _2}{\eta _1}\frac{\textrm{sin}\varphi _{1G}}{\textrm{cos}\varphi _{1G}}\left( \frac{\textrm{cos}\varphi _{1G}}{\textrm{sin}\varphi _{1G}}\right) ^{\varepsilon _{1G}-1} \nonumber \\&=-\frac{\eta _2}{\eta _1}\textrm{tan}^{2-\varepsilon _{1G}}\varphi _{1G} \end{aligned}$$
(14)

Similarly, Eq. (9) becomes the following equation at point G.

$$\begin{aligned} \frac{y_G}{x_G}\ =\ \frac{\eta _2}{\eta _1}\tan ^{-\varepsilon _{1G}}\varphi _{1G} \end{aligned}$$
(15)

According to Eqs. (14) and (15), by eliminating \(\varepsilon _{1G}\), we obtain the following Eq. (16):

$$\begin{aligned} \textrm{tan}^2\varphi _{1G}\ \approx \ -\frac{x_G}{y_G}\textrm{tan}\gamma _G \end{aligned}$$
(16)

The mediator variable \(\varphi _{1G}\) is then approximated by Eq. (17) as follows:

$$\begin{aligned} \varphi _{1G} \approx \textrm{arctan}\left( \sqrt{-\frac{x_G}{y_G}\textrm{tan}\gamma _G}\right) \end{aligned}$$
(17)

As described above, by using the inverse affine transformation, the normal vector at point G is not correctly derived and an approximation formula is included. Therefore, when the exponent is calculated using the coordinates of point G and the normal vector \(\varvec{n}_3\), it is not uniquely determined. The exponents obtained from \({x_G}\) and \({y_G}\) are almost the same value, but there is a distortion error due to the affine transformation of the coordinates. Therefore, the average is taken to mitigate the calculation error. Therefore, to mitigate the calculation error, transform both sides of equation (9) into logarithms and consider the average of the exponents obtained from \(x_G\) and \(y_G\), the exponent \(\varepsilon _{1G}\) of the superellips is expressed as follows:.

$$\begin{aligned} \varepsilon _{1G}\ =\ {\frac{1}{2}}{\left( \frac{\textrm{log}\left( \frac{x_G}{\eta _1}\right) }{\textrm{log}(\textrm{sin}\varphi _{1G})} + \frac{\textrm{log}\left( \frac{y_G}{\eta _2}\right) }{\textrm{log}(\textrm{cos}\varphi _{1G})}\right) } \end{aligned}$$
(18)

Finally, the exponential value \(\varepsilon _1\) is applied to the parallelogram-shaped superellipse. The result is an approximation of the Minkowski sum using a superellipse in the XY plane, as shown in the right of Fig. 8

Fig. 13
figure 13

Procedure for approximating the superellipsoid of Minkowski sums from two to three dimensions. Left: Derivation of radius parameter \(\eta _3\) for a superellipsoid. Right: Overlapping a superellipsoid on a point on the Minkowski sum

4.2 Approximation by superellipsoid

To expand from two to three dimensions, it is necessary to derive the radius parameter \(\eta _3\) along the Z-axis and the exponential value \(\varepsilon _2\). First, the radius parameter \(\eta _3\) is obtained as shown in the left of Fig. 13. Point T from the Minkowski sum normal to the Z-axis is considered because it is necessary to consider the point with the largest component along the Z-axis. According to the arrangement condition of the rotational ellipsoid in this study, the points from each ellipsoid that constitute point T are \((0,0, \beta _1)\) and \((0,0, \beta _2)\) on the Z-axis. Therefore, the coordinates of point T are \((0,0, \beta _1+\beta _2)\) and the radius parameter \(\eta _3=\ \ \beta _1+\beta _2\). Subsequently, the exponential value \(\varepsilon _2\) is calculated in the same manner as in the exponent calculation in Sect. 4.1, and the shape is adjusted as shown in the right of Fig. 13. By replacing Eq. (7) with the variable w and the composite radius parameter \(\eta _4\) as in the following equation, Eq. (17) derived in the exponent calculation in Sect. 4.1.2 is used as follows:

$$\begin{aligned} \left| \frac{w}{\eta _4}\right| ^{\frac{2}{\varepsilon _2}}+\left| \frac{z}{\eta _3}\right| ^{\frac{2}{\varepsilon _2}}\ =\ 1 \end{aligned}$$
(19)

\(w/\eta _4\) is expressed as follows:

$$\begin{aligned} \frac{w}{\eta _4}&= \left( \left| \frac{x}{\eta _1}\right| ^{\frac{2}{\varepsilon _1}}+\left| \frac{y}{\eta _2}\right| ^{\frac{2}{\varepsilon _1}}\right) ^{\frac{\varepsilon _1}{2}} \end{aligned}$$
(20)
$$\begin{aligned}&= \frac{\left( \left( \eta _2x\right) ^{\frac{2}{\varepsilon _1}}+\left( \eta _1y\right) ^{\frac{2}{\varepsilon _1}}\right) ^{\frac{\varepsilon _1}{2}}s}{{\eta _1\eta _2}} \end{aligned}$$
(21)

Subsequently, the variables w and the composite radius parameter \(\eta _4\), respectively, are expressed as follows:

$$\begin{aligned} w&= \frac{\left( \left( \eta _2x\right) ^{\frac{2}{\varepsilon _1}}+\left( \eta _1y\right) ^{\frac{2}{\varepsilon _1}}\right) ^{\frac{\varepsilon _1}{2}}}{\sqrt{\eta _1\eta _2}} \end{aligned}$$
(22)
$$\begin{aligned} \eta _4&= \sqrt{\eta _1\eta _2} \end{aligned}$$
(23)

In three dimensions, the intersection point of the superellipsoid and Minkowski sum should be a point on the Minkowski sum that is distant from points Q, R, and T. Therefore, as shown in Fig. 14, a point H\(^\prime \)(\(x_{H}^\prime \), \(y_{H}^\prime \), \(z_{H}^\prime \)), on the Minkowski sum is obtained using the normal vector \(\varvec{n}_4^\prime \) perpendicular to the plane formed by points Q, R, and T.

Fig. 14
figure 14

Procedure for determining the shape of a superellipsoid by overlapping the point H of the Minkowski sum. Left: Deriving point H\(^\prime \) from the Minkowski sum by the normal vector \(\varvec{n}_4^\prime \). Right: Calculating the exponent \(\varepsilon _2\) so that the inverse affine transformation of the point H\(^/prime\) overlaps the superellipsoid

Subsequently, an inverse affine transformation is performed on point H\(^\prime \) to obtain point H(\(x_H\), \(y_H\), \(z_H\)). The tangent plane of point H is approximated as intersecting the XY plane at the angle \(\gamma _H\) rad. Then, using Eq. (17), the mediator variable \(\varphi _{2H}\) at point H is expressed as follows:

Algorithm 1
figure h

Flow of collision detection

$$\begin{aligned} \varphi _{2H}&\approx \textrm{arctan}\left( \sqrt{-\frac{w_H}{z_H}\textrm{tan}\gamma _H}\right) \end{aligned}$$
(24)
$$\begin{aligned} w_H&= \frac{\left( \left( \eta _2x_H\right) ^{\frac{2}{\varepsilon _1}}+\left( \eta _1y_H\right) ^{\frac{2}{\varepsilon _1}}\right) ^{\frac{\varepsilon _1}{2}}}{\sqrt{\eta _1\eta _2}} \end{aligned}$$
(25)

Considering Eq. (18) in \(w_H\) and \(z_H\), using \(\varphi _{2H}\), the exponent \(\varepsilon _{2H}\) becomes the following equation:.

$$\begin{aligned} \varepsilon _{2H}={\frac{1}{2}}\left( \frac{\textrm{log}\left( \frac{w_H}{\eta _4}\right) }{\textrm{log}\left( \textrm{sin}\varphi _{2H}\right) }+\frac{\textrm{log}\left( \frac{z_H}{\eta _3}\right) }{\textrm{log}\left( \textrm{cos}\varphi _{2H}\right) }\right) \end{aligned}$$
(26)

The pseudo-code to determine the contact between rotational ellipsoids \(A_1\) and \(A_2\) is shown in Algorithm 1, with the center of \(A_2\) at O\(^{\prime \prime \prime }\). The calculation process shown above is the 24th line of the pseudo-code, and all the parameters necessary for Eq. (6) of the superellipsoid are obtained. When judging collision, the center coordinate O\(^{\prime \prime \prime }\) of \(A_2\) is substituted into Eq. (6), and the collision can be judged based on the relationship between the two coordinates.

Fig. 15
figure 15

Minkowski sum (blue area) and superellipsoid (green area) approximation results for a combination of four rotational ellipsoids (red area)

5 Experiment

In the experiment, we evaluated the method in terms of error and computation time. In the error evaluation experiment, this method and method [7, 8] were compared in terms of error with the Minkowski sum. Moreover, we investigated the number of faces in the Minkowski sum that was as accurate as our method.

5.1 Error comparison experiment between Minkowski sum and our method

Error evaluation experiments demonstrate the effectiveness of our method by comparing it with a similar method [7, 8] that approximates the Minkowski sum with a circumscribed ellipsoid and uses inequalities for collision detection. The error with the Minkowski sum was evaluated as the distance between the face of the Minkowski sum and a point on the surface of the approximate function for all combinations of parameters of the rotational ellipsoid. The distance between any face of the Minkowski sum and any a point on the surface of the approximate function was calculated using the distance between point and triangle in 3D method (Geometric Tools) [16]. The distances to the nearest neighbor points of the approximate surface for all faces of the Minkowski sum were summed and then normalized by dividing with the number of faces and square root of the area of the Minkowski sum. The 840 combinations of rotational ellipsoids to be evaluated were chosen from angle \(\theta \) [0, 15, 30, 45, 60, 75, 90], semi-major axis \(\alpha _i\) [1, 2, 3, 4, 5], and semi-minor axis \(\beta _i\) [1,..., \(\alpha _i\)] to avoid overlap. The average number of faces in the evaluation experiments was 1520.0 for the Minkowski sum of the true values, 1537.1 for the superellipsoid of our method, and 1537.1 for the ellipsoid of the comparison method.

First of all, the results of this method are shown. Figure 15 shows the four Minkowski sums for each combination of rotational ellipsoids and the superellipsoids that approximate them. The errors were so minimal that they could not be observed. Figure 16 is a histogram of the errors in the evaluation experiment, where the horizontal axis is the error interval and the vertical axis is the number of counts in the experiment. Our method has a mean absolute error of \(3.64\times {10}^{-3}\) with a standard deviation of \(1.26\times {10}^{-3}\). Also, Fig. 17 shows the outermost and innermost distances of the superellipsoid to a plane with Minkowski sums for each combination of rotational ellipsoids, as well as the average error. The average of the outermost distance is \(5.43\times {10}^{-3}\) and the average of the innermost distance is \(-17.24\times {10}^{-3}\), so this method is not conservative.

Next, a comparison with method [7, 8] is shown in Fig. 18. The method [7, 8] has a mean absolute error of \(26.04\times {10}^{-3}\) with a standard deviation of \(21.04\times {10}^{-3}\). This means that our method has a smaller average error of \(86.0\%\), and the error is smaller regardless of the combination of ellipsoids.

5.2 Investigation of Minkowski sum face counts with accuracy equivalent to this method

The accuracy of the Minkowski sum obtained by Convex Hull is based on the mesh, whereas our method exhibits no such dependence. Therefore, we investigated the number of faces for Minkowski sums using Convex Hull, which is equivalent in accuracy to our method. In this investigation, the Minkowski sum composed of high-density faces (average number of faces: 33064.0) was assumed to be the true value, and the errors were compared with those of the superellipsoid (average number of faces: 32048.4) while changing the density of the faces of the Minkowski sum. The investigation was conducted using ten combinations of five parameters randomly determined for the angle \(\theta \) [0, 1, 2, 3,..., 88, 89, 90] between the major semiaxes of the rotational ellipsoids, the major semi-major axis \(\alpha _i\) [1, 2, 3,..., 8, 9, 10], and the minor semi-minor axis \(\beta _i\) [1,..., \(\alpha _i\)] of each rotational ellipsoid. The left of Fig. 19 shows the variation in the error of the Minkowski sum with the number of faces, and the average error of the superellipsoid for the ten combinations. In the face range from 5000 to 35,000, the linear approximate line of error variation for all patterns is shown in the right of Fig. 19. Since the average error of the superellipsoid and the approximate line intersect at about 19000 of face in the right figure, our method is as accurate as the Minkowski sum with about 19000 faces.

Fig. 16
figure 16

Histogram of errors in the superellipsoid approximation and Minkowski sum. The vertical axis is the number of counts of experiments, and the horizontal axis is the interval of errors

Fig. 17
figure 17

Mean absolute and outermost and innermost errors for each ellipsoid combination. The vertical axis is the error, and the horizontal axis is the combination number of the rotational ellipsoid

Fig. 18
figure 18

Comparison with the approximation method by circumscribed ellipsoids [7, 8]. Left: Our method of approximating Minkowski sum with a superellipsoid. Right: The method [7, 8] of approximating Minkowski sum with a ellipsoid

5.3 Execution time measurements

As shown in Algorithm 1, collision detection in this method does not require the generation of the mesh, and is based on the magnitude relationship using Eq. (6) after calculating the parameters. Since the determination of this method is based on a single computation of the inequality magnitude relationship, there is no overhead to obtain a superellipsoid. Therefore, in this experiment, we measured the time taken to compute all the parameters of the superellipsoid, which is the 24th line of Algorithm 1. It is necessary to evaluate the execution time for various combinations because of the variability caused by the convergence calculations. Therefore, the angles of the major semi-major axis vector of the rotational ellipsoid and the major and semi-minor axes of each rotational ellipsoid were randomly selected, and their execution times were measured. We randomly selected 100 combinations of angle \(\theta \) [0, 1, 2, 3,..., 88, 89, 90], semi-major axis \(\alpha _i\) [1, 2, 3,..., 8, 9, 10], and semi-minor axis \(\beta _i\) [1,..., \(\alpha _i\)], and calculated the average running time of 10000 calculations for each combination. The program for measuring execution time was written in C++14 using Eigen (3.4.0). The computers listed in Table 1 were used to run the program.

The results showed that the average time per parameter calculation was 5.98 \(\upmu \)sec, the maximum was 9.06 \(\upmu \)sec, and the standard deviation was \(1.29\times {10}^{-3}\). Overall, the computation was fast, regardless of the combination.

5.4 Discussion and future work

Our method approximated the Minkowski sum of two rotational ellipsoids using algebraic computation. The approximation uses a superellipsoid, which is an implicit function, making it easy to perform point inclusion check. The error evaluation of the experimental results averaged \(3.61\times 10^{-3}\), which is equivalent to an approximation accuracy of about 19000 for the mesh of the Minkowski sum by Convex Hull. Also, the processing speed was fast, averaging 5.98 \(\upmu \)sec. Thus, our method is constant in accuracy and fast compared to Convex Hull’s method, which requires the time complexity of computation \(\varvec{O}(n^2)\) when the number of points in the ellipsoid is n, and whose error depends on the mesh.

The accuracy and speed of this method and the simplicity of collision detection are theoretically certain. Here, we compare our method with other methods that approximate Minkowski sums. The methods [7, 8, 10, 11] approximate the Minkowski sum with an ellipsoid, but the approximation error is large. For example, if the ellipticity of two rotational ellipsoids is large \((\alpha _i>> \beta _i)\), the Minkowski sum looks like a rectangle, but an ellipsoid cannot represent the shape. Our method approximates with a superellipsoid that varies in shape depending on the value of exponents, and thus has good approximation accuracy. Closed-form parametric formula with affine transformation and offset adjustment was presented [12]. It also shows that the volume and surface area errors are a few percent. However, since it is not an implicit function, a solution search must be performed when collision detection is performed. Our method is able to perform fast contact detection even for complex shapes by using multiple rotational ellipsoids to approximate an object. In the future, we plan to extend the method to contact detection of general ellipsoids to further enhance its applicability.

Fig. 19
figure 19

Error transition of Minkowski sum with number of faces and average error of superellipsoid (average number of faces for true Minkowski sum is 33064.0, average number of faces for superellipsoid is 32048.4) Right: Additional linear approximation line in the range of 5000 to 35000 faces is shown

6 Conclusion

In this study, we propose a method for approximating the Minkowski sum of rotational ellipsoids using a superellipsoid for collision detection. Our method provides a highly accurate approximation of the Minkowski sum, and the computational time required for this approximation takes average 5.98 \(\upmu \)sec, which is extremely short. In addition, the point inclusion check is performed instantaneously when it is used for contact determination. Future prospects include the approximate computation of general ellipsoids and increasing dimensionality.

Table 1 Computer specification