Math

abs, acos, asin, atan, atof, atoi, cos, fabs, hypot, log, max, min, pow, random, rng, round, sgn, sin, SortArrayDbl, SortArrayInt, sqrt, tan

SortArrayDbl

Description 

 SortArrayDbl(
   double *Int_ArrayDbl,
   long  Int_Count
);

This function can sort an array of double values. The sorting is ascending.

Int_Count parameter is the position of the desired value (0 for the first position).

Parameters

double *Int_ArrayDbl

A name of the array.

long Int_Count

Number of bytes.

double data[1000];
int size;
double median;
char text[64];
ScanObjects();
size = Get_NumObjects(FIELD_LAST, 0);
if (size>0)
{
   Get_ObjectFeatureData("Area", data, FIELD_LAST, 0);
   SortArrayDbl(data, size);
   median = data[size/2];
   sprintf(text, "Median is: %f","median");
   WaitText(3, text);
}

See Also 
SortArrayInt

SortArrayInt

Description 

 SortArrayInt(
   int *Int_ArrayInt,
   long  Int_Count
);

This function can sort an array of integer values. The sorting is ascending.

Int_Count parameter is the position of the desired value (0 for the first position).

Parameters

int *Int_ArrayInt

A name of the array.

long Int_Count

Number of bytes.

abs

Description 

 abs(
   int  Int_X
);

This function returns the absolute value of its integer parameter i.

Parameters

int Int_X

X coordinate.

acos

Description 

 acos(
   double  x
);

This function calculates the arccosine of the argument.

Parameters

double x

Number to calculate the arccosine of.

Return Values

The acos function returns the arccosine of x.

asin

Description 

 asin(
   double  x
);

This function calculates the arcsine of the argument.

Parameters

double x

Number to calculate the arcsine of.

Return Values

The asin function returns the arcsine of x.

atan

Description 

 atan(
   double  x
);

This function finds the arctangent of the argument.

Parameters

double x

Number to calculate the arctangent of.

Return Values

The atan function returns the arctangent of x.

atof

Description 

 atof(
   char *Int_Buf1
);

This function converts a character string to a double-precision floating point value.

Parameters

char *Int_Buf1

First buffer.

Return Values

The atof function returns a double-precision floating point, produced by interpreting the input characters as a number. The return value is 0, if the input cannot be converted to a double. The return value is undefined in case of overflow. The function expects string to have the following form: [whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits].

atoi

Description 

 atoi(
   char *Int_Buf1
);

This function converts a character string to an integer value.

Parameters

char *Int_Buf1

First buffer.

Return Values

The atoi function returns an integer value, produced by interpreting the input characters as a number. The return value is 0, if the input cannot be converted to an integer. The return value is undefined in case of overflow.

cos

Description 

 cos(
   double  x
);

This function calculates the cosine of the argument.

Parameters

double x

Angle in radians.

Return Values

The cos function returns the cosine of x.

fabs

Description 

 fabs(
   double  x
);

This function returns the absolute value of its double parameter x.

Parameters

double x

Double value of which the absolute value will be calculated.

hypot

Description 

 hypot(
   double  x,
   double  y
);

This function returns the hypothenuse of a triangle with sides of length x and y.

Parameters

double x

Double value which defines the length of a side of a triangle, connecting to an angle of 90 degrees.

double y

Double value which defines the length of a side of a triangle, connecting to an angle of 90 degrees.

log

Description 

 log(
   double  Int_DX
);

This function returns the logarithm with base 10 of double parameter x.

Parameters

double Int_DX

Double value of which the logarithm base 10 will be calculated

max

Description 

 max(
   double  val1,
   double  val2
);

This function compares two values and returns the value of the greater one.

Parameters

double val1

Value to be compared.

double val2

Value to be compared.

min

Description 

 min(
   double  val1,
   double  val2
);

This function compares two values and returns the value of the smaller one.

Parameters

double val1

Value to be compared.

double val2

Value to be compared.

pow

Description 

 pow(
   double  x,
   double  y
);

This function computes x raised to the power of y.

Parameters

double x

Number to be raised.

double y

Power of x.

Return Values

The function returns x raised to the y-th power. If x is not 0.0 and y is 0.0, pow returns the value 1. If x is 0.0 and y is negative, pow returns 0.0. If both x and y are 0.0, or if x is negative and y is not an integer, the function returns 0.0. If an overflow results, the function returns the maximum value to fit in a double.

random

Description 

 random(
   int  seed
);

This function generates random integer in the range 0 to 32767.

Parameters

int seed

If positive, function sets a random generator starting point. If negative, function generates random integer in the range 0 to 32767.

Return Values

The random function returns random integer in the range 0 to 32767. Use parameter to set random integer generator starting point. When you use the function to set random generator starting point, function returns -1. If parameter is negative function returns random integer.

rng

Description 

 rng(
   double  x,
   double  Int_Low,
   double  Int_High
);

This function returns x if x lies between low and high inclusive, low if x is smaller than low and high if x is larger than high.

Parameters

double x

Double value to be put in range.

double Int_Low

Lower limit of range.

double Int_High

Upper limit of range.

round

Description 

 round(
   double  x
);

This function returns double parameter x, rounded to the nearest integer.

Parameters

double x

Double value to be rounded.

sgn

Description 

 sgn(
   double  x
);

This function computes the signum.

Parameters

double x

If positive, function returns 1.0. If negative, function returns -1.0. If equals to zero, function returns 0.0;

Return Values

This function returns 1.0, 0.0 or -1.0 respectively, when parameter is is positive, zero or negative

sin

Description 

 sin(
   double  x
);

This function finds the sine of the argument.

Parameters

double x

Angle in radians.

Return Values

The sin function returns the sine of x.

sqrt

Description 

 sqrt(
   double  x
);

This function calculates the square root of x.

Parameters

double x

Double value of which the square root will be calculated.

Return Values

If x is negative, the function returns FALSE.

tan

Description 

 tan(
   double  x
);

This function finds the tangent of the argument.

Parameters

double x

Angle in radians.

Return Values

The tan function returns the tangent of x.