You are here: Start » Programming Tips » Formulas Migration Guide to version 5.0

Formulas Migration Guide to version 5.0

Introduction

Aurora Vision Studio 5.0 comes with many new functions available directly in the formula block. Moreover, many operations, which were previously done using filters, can now be accomplished directly in the formulas. This way, the complexity of the inspection program can be reduced significantly. This document focuses on pointing out some of the key differences between formulas in Aurora Vision Studio 5.0 and its previous versions. For all functions please refer to the Formulas article in the Programming Reference section of this documentation.

Conditional operator

Before 5.0, a ternary operator ?: was used to perform a conditional execution inside a formula. This compact syntax, however, might prove quite challenging and hard to understand, especially to users, who are not familiar with textual programming. In order to overcome this issue, a more user friendly if-then-else syntax has been introduced, while also keeping the option of using the ternary operator.

In the example below, apart from the new conditional syntax, a new square function has also been used, instead of inA*inA.

Before 5.0
From 5.0

Mathematical functions

  • Lerp - computes a linear interpolation between two numeric values.

    Before 5.0

    From 5.0

  • Square - raises the argument to the power of two.
  • Hypot - calculates the hypotenuse of triangle.
  • Clamp - limits the specific value to the range.

Statistic and array processing functions

  • indexOfMin - returns the index of the smallest of the values in the input array.
  • indexOfMax - returns the index of the largest of the values in the input array.
  • Count value in array - depending on the chosen variant, returns the number of items equal to True or counts the number of elements in the array that are equal to the value given in the second argument.

    Before 5.0

    From 5.0

  • contains - checks if the specified array contains a value.
  • Find - searches the specified array for instances equal to the given value and return the index of the first found item.

    Before 5.0

    From 5.0

  • findLast - searches the specified array for instances equal to the given value and return the index of the last found item.
  • findAll - searches the specified array for instances equal to the given value and return an array of indices of all found items.
  • minElement - returns an array element that corresponds to the smallest value in the array of values.

    Before 5.0

    From 5.0

  • maxElement - returns an array element that corresponds to the biggest value in the array of values.
  • removeNils - removes all Nil elements from an array.

    Before 5.0

    From 5.0

  • flatten - takes an array of arrays, and concatenates all nested arrays creating a single one-dimensional array containing all individual elements.

    Before 5.0

    From 5.0

  • select - selects the elements from the array of items for which the associated predicate is True.

    Before 5.0

    From 5.0

Geometry processing functions

  • angleNorm - normalizes the given angle.

    Before 5.0

    From 5.0

  • angleDiff - calculates an absolute difference between two given angles.
    angleTurn - calculates a directional difference between two given angles.

    Before 5.0

    From 5.0

  • distance - calculates the distance between a point and the closest point of a geometric primitive (one of: Point2D, Segment2D or Line2D).

    Before 5.0

    From 5.0

  • area - calculates the surface area of a given geometric primitive.

    Before 5.0

    From 5.0

  • dot - calculates the dot product of two vectors.
  • normalize - normalizes the specified vector.

For complete information about the syntax and semantics please refer to the Formulas article in the Programming Reference section of this documentation.