vpRamp(3)

πŸ’– vpRamp πŸ’–

okay bestie, this is a page from the Library Functions Manual, and today's main character is vpRamp β€” she initializes an array with a piecewise-linear ramp. slay. let's get into it πŸŽ€


✨ 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 β€” the output array, bestie. this is where the good stuff gets written πŸ’…
  • stride β€” how many bytes you hop to get from one array element to the next.
  • num_points β€” how many entries live in the input arrays (ramp_x and ramp_y).
  • ramp_x β€” input array full of indices into array.
  • ramp_y β€” input array full of the values you're storing into array.

πŸ¦‹ DESCRIPTION πŸ¦‹

vpRamp is a utility routine for initializing linear arrays of floating-point numbers with piecewise-linear ramps. it's giving ✨utility✨ and honestly? we're obsessed.

so 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 you store into the array. and the elements of array whose indexes land in between two of those X values? they get linearly-interpolated Y values. no cap, that's the whole vibe. πŸ“ˆ

heads up bestie: the values in ramp_x must be strictly increasing. like, non-negotiable. fr fr.

the stride argument may be used to skip array elements or to initialize arrays with a non-standard stride. and if your output array is just a simple linear array of type float, then stride should be sizeof(float). easy math, iykyk.

this function is useful for creating lookup tables used for opacity transfer functions (see vpSetClassifierTable(3)) and shading functions (see vpSetLookupShader(3)). lookup table queen πŸ‘‘


πŸ’€ ERRORS πŸ’€

the normal return value is VP_OK. she ate. but 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 🌈


and that's the whole page, bestie πŸ’œ this was vpRamp(3) from the VolPack library β€” thanks for reading, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from