Skip to content

Mathematical Operations🔗

Trigonometric Functions🔗

Table 1: Trigonometric functions
Operation Meaning HALCON Operator
sin(a) sine of a tuple_sin
cos(a) cosine of a tuple_cos
tan(a) tangent of a tuple_tan
asin(a) arc sine of a in the interval \([-\pi/2,\pi/2], a \in [-1, 1]\) tuple_asin
acos(a) arc cosine a in the interval \([-\pi/2,\pi/2], a \in [-1, 1]\) tuple_acos
atan(a) arc tangent a in the interval \([-\pi/2,\pi/2], a \in [-\infty, +\infty]\) tuple_atan
atan2(a1,a2) arc tangent a1/a2 in the interval \([-\pi,\pi]\) tuple_atan2
sinh(a) hyperbolic sine of a tuple_sinh
cosh(a) hyperbolic cosine of a tuple_cosh
tanh(a) hyperbolic tangent of a tuple_tanh
asinh(a) inverse hyperbolic sine of a tuple_asinh
acosh(a) inverse hyperbolic cosine of a tuple_acosh
atanh(a) inverse hyperbolic tangent of a tuple_atanh

Exponential Functions🔗

Table 2: Exponential functions
Operation
Meaning HALCON operator
exp(a) exponential function \(e^a\) tuple_exp
exp2(a) base 2 exponential function \(2^a\) tuple_exp2
exp10(a) base 10 exponential function \(10^a\) tuple_exp10
log(a) natural logarithm \(\ln(a)\), \(a>0\) tuple_log
log2(a) base 2 logarithm, \(\log_2(a)\), \(a>0\) tuple_log2
log10(a) base 10 logarithm, \(\log_{10}(a)\), \(a>0\) tuple_log10
pow(a1,a2) \(a1^{a2}\) tuple_pow
ldexp(a1,a2) \(a1\cdot 2^{\operatorname{floor}(a2)}\) tuple_ldexp
tgamma(a) gamma function \(\Gamma(a)\) tuple_tgamma
lgamma(a) logarithm of the absolute value of the gamma function \(\log( \| \Gamma(a) \| )\) tuple_lgamma
erf(a) error function \(erf(a)\) tuple_erf
erfc(a) complementary error function \(erfc(a)\) tuple_erfc

Numerical Functions🔗

Table 3: Numerical functions
Operation Meaning HALCON operator
min(t) minimum value of the tuple tuple_min
min2(t1,t2) elementwise minimum of two tuples tuple_min2
max(t) maximum value of the tuple tuple_max
max2(t1,t2) elementwise maximum of two tuples tuple_max2
sum(t) sum of all tuple elements or string concatenation tuple_sum
mean(a) mean value tuple_mean
deviation(a) standard deviation tuple_deviation
cumul(a) cumulative sums of a tuple tuple_cumul
median(a) median of a tuple tuple_median
select_rank(a,i) element at rank i of a tuple tuple_select_rank
sqrt(a) square root \(\sqrt{a}\) tuple_sqrt
cbrt(a) cube root \(\sqrt[3]{a}\) tuple_cbrt
hypot(a,b) hypotenuse \(\sqrt{a^2+b^2}\) tuple_hypot
deg(a) convert radians to degrees tuple_deg
rad(a) convert degrees to radians tuple_rad
real(a) convert integer to real tuple_real
int(a) truncate real to integer tuple_int
round(a) convert real to integer tuple_round
abs(a) absolute value of a (integer or real) tuple_abs
fabs(a) absolute value of a (always real) tuple_fabs
ceil(a) smallest integer value not smaller than a tuple_ceil
floor(a) largest integer value not greater than a tuple_floor
fmod(a1,a2) fractional part of a1/a2, with the same sign as a1 tuple_fmod
sgn(a) elementwise sign of a tuple tuple_sgn

Example

The following example (file name: euclid_distance.hdev) shows the use of some numerical functions.

Preview Restrictions

HDevelopEVO does not support vectors yet.

V1 := [18.8,132.4,33,19.3]
V2 := [233.23,32.786,234.4224,63.33]
Diff := V1 - V2
Distance := sqrt(sum(Diff * Diff))
Dotvalue := sum(V1 * V2)

First, the Euclidean distance of the two vectors V1 and V2 is computed by using the formula:

\[d = \sqrt{\sum_i(V1_i - V2_i)^2}\]

The difference and the multiplication (square) are successively applied to each element of both vectors. Afterward, sum computes the sum of the squares. Then the square root of the sum is calculated. After that, the dot product of V1 and V2 is determined by the formula:

\[\left<V1,V2\right> = \sum_i(V1_i \cdot V2_i)\]