---
name: "Ramp"
section: "3"
platform: "linux"
package: "libvolpack1-dev"
version: "1.0b3-10"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Ramp"
---

# Ramp(3)

initialize an array with a piecewise-linear ramp

## NAME

vpRamp - initialize an array with a piecewise-linear ramp

## SYNOPSIS

\#include \<volpack.h\>

vpResult

**vpRamp(***array, stride, num\_points, ramp\_x, ramp\_y***)**

-

  float \**array;*

-

  int *stride;*

-

  int *num\_points;*

-

  int \**ramp\_x;*

-

  float \**ramp\_y;*

## ARGUMENTS

- *array*

  Output array.

- *stride*

  Stride from one array element to the next, in bytes.

- *num\_points*

  Number of entries in the input arrays (*ramp\_x* and *ramp\_y*).

- *ramp\_x*

  Input array containing indices into *array*.

- *ramp\_y*

  Input array containing values to store into *array*.

## DESCRIPTION

**vpRamp** is a utility routine for initializing linear arrays of floating-point numbers with piecewise-linear ramps.  A ramp is defined by a set of (x, y) pairs.  The X coordinates are integers that index entries in the *array* argument, and the Y coordinates are floating-point values to store into the array.  Linearly-interpolated Y values are stored in array elements with indexes in between two of the X values.

The values in *ramp\_x* most be strictly increasing.  The *stride* argument may be used to skip array elements or to initialize arrays with a non-standard stride.  If the output array is a simple linear array of type float then the stride should be sizeof(float).

This function is useful for creating lookup tables used for opacity transfer functions (see vpSetClassifierTable(3)) and shading functions (see vpSetLookupShader(3)).

## ERRORS

The normal return value is VP\_OK.  The following error return value is possible:

- VPERROR\_BAD\_VALUE

  The number of points is less than one or the X values are not strictly increasing.

## SEE ALSO

[VolPack(3)](/VolPack/3.md)
