System Curves

The variable type UMC_CURVE is used to represent many different parameters in the Ultrasonix software; vertical and lateral TGC’s, aperture openings, and delay curves are all typical parameters that use this type.

The definition of the type is as follows:

class UMC_CURVE
{
public:
int t;
int m;
int b;
int vm;
};

There are 4 parameters that represent the curve: t, m, b, and vm. The curve represents a 100 x 100 unit box that is interpolated based on the parameter that the curve represents.

• t is the horizontal position of the top-most point of the curve. The range is 0 - 100. Note that this point’s vertical position is always fixed to 0.
• m is the horizontal position of the mid-point of the curve. The range is 0 – 100.
• b is the horizontal position of the bottom-most point of the. The range is 0 – 100. Note that this point’s vertical position is always fixed to 100.
• vm is the vertical position of the mid-point of the curve. The range is 0 – 100.

The figure below, shows a visual representation of the curve represented by the following values. Note that the actual interpolation curve is a piece-wise linear curve as demonstrated by the code. Only for visual representation, the curve looks smooth.

 t=100 m=18 b=0 vm=60 Interpolation

Here are some functions that interpolate a UTX_CURVE variable:

int getCurvePosition(int percentage, int maxlength)
{
return (int) (( (double)percentage * (double)maxlength) / 100.0);
}

int getCurveValue(UTX_CURVE curve, int maxX, int maxY, int x)
{
POINT p1, p2, p3;

// POINTS
// getting the coordinates of the zone points; curve contains the % coordinates
// and getCurvePosition() converts it to pixel coordinates point 1
p1.x = 0;
p1.y = getCurvePosition(curve.t, maxY);

// point 2
p2.x = getCurvePosition(curve.vm, maxx);
p2.y = getCurvePosition(curve.m, maxY);

// point 3
p3.x = maxx;
p3.y = getCurvePosition(curve.b, maxY);

// SLOPES
// if the line has reached the middle point already we have to
// calculate slope for a second line which will go to the bottom zone point
double slope;

if (p2.x > x)
{
slope = (double)(p2.y - p1.y) / (double)(p2.x - p1.x);
}
else
{
slope = (double)(p3.y - p2.y) / (double)(p3.x - p2.x);
}

// Y-INTERCEPTS
int yintercept1 = -p1.y;
int yintercept2 = (int)((slope * (double)p2.x) - p2.y);

// return values
int value;
if (p2.x > x)
{
// calculation of the x value
value = (int)((slope * (double)x) - yintercept1);
}
else
{
// calculation of the x value
value = (int)((slope * (double)x) - yintercept2);
}

return value;
}