Operators

# elliptic_axis_xld (Operator)

## Name

elliptic_axis_xld — Parameters of the equivalent ellipse of contours or polygons.

## Signature

elliptic_axis_xld(XLD : : : Ra, Rb, Phi)

## Description

The operator elliptic_axis_xld calculates the radii and the orientations of the ellipses having the same orientation and the same aspect ratio as the input contours or polygons. The length of the major radius Ra and the minor radius Rb as well as the orientation of the main axis with regard to the horizontal (Phi) are determined. The angle is indicated in radians. It is assumed that the contours or polygons are closed. If this is not the case area_center_xld will artificially close the contours or polygons.

Calculation:

```        If the moments M20, M02 and M11 are
normalized to the area (see moments_xld),
the radii Ra and Rb are calculated as:

Ra = sqrt(8.0*(M20+M02+sqrt((M20-M02)^2+4.0*M11^2)))/2.0
Rb = sqrt(8.0*(M20+M02-sqrt((M20-M02)^2+4.0*M11^2)))/2.0

The orientation Phi is defined by:

Phi = -0.5 * atan2(2.0 * M11,M02 - M20)
```

It should be noted that elliptic_axis_xld only returns useful results if the contour or polygon encloses a region in the plane. In particular, the contour or polygon must not intersect itself. This is particularly important if open contours or polygons are passed because they are closed automatically, which can produce a self-intersection. To test whether the contours or polygons intersect themselves, test_self_intersection_xld can be used. If the contour or polygon intersects itself, useful values for the ellipse parameters can be calculated with elliptic_axis_points_xld.

If more than one contour or polygon is passed, the results are stored in tuples in the same order as the respective contours or polygons in XLD.

## Parallelization

• Multithreading type: reentrant (runs in parallel with non-exclusive operators).
• Automatically parallelized on tuple level.

## Parameters

XLD (input_object)  xld(-array) object

Contours or polygons to be examined.

Ra (output_control)  real(-array) (real)

Assertion: Ra >= 0.0

Rb (output_control)  real(-array) (real)

Assertion: Rb >= 0.0 && Rb <= Ra

Phi (output_control)  real(-array) (real)

Angle between the major axis and the x axis (radians).

Assertion: - pi / 2 < Phi && Phi <= pi / 2

## Complexity

If N is the number of contour or polygon points, the runtime complexity is O(N).

## Result

elliptic_axis_xld returns 2 (H_MSG_TRUE) if the input is not empty. If the input is empty the behavior can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.