fbpx
Wikipedia

Clamping (graphics)

In computer science, clamping, or clipping is the process of limiting a value to a range between a minimum and a maximum value. Unlike wrapping, clamping merely moves the point to the nearest available value.

Y = clamp(X, 1, 3)
X Y
0 1
1 1
2 2
3 3
4 3

In Python, clamping can be defined as follows:

def clamp(x, minimum, maximum): if x < minimum: return minimum if x > maximum: return maximum return x 

This is equivalent to max(minimum, min(x, maximum)) for languages that support the functions min and max.

Uses edit

Several programming languages and libraries provide functions for fast and vectorized clamping. In Python, the pandas library offers the Series.clip[1] and DataFrame.clip[2] methods. The NumPy library offers the clip[3] function. In the Wolfram Language, it is implemented as Clip[x, {minimum, maximum}].[4]

In OpenGL, the glClearColor function takes four GLfloat values which are then 'clamped' to the range  .[5]

One of the many uses of clamping in computer graphics is the placing of a detail inside a polygon—for example, a bullet hole on a wall. It can also be used with wrapping to create a variety of effects.

References edit

  1. ^ "Pandas Series.clip method documentation". Retrieved 2023-10-15.
  2. ^ "Pandas DataFrame.clip method documentation". Retrieved 2023-10-15.
  3. ^ "NumPy clip function documentation". Retrieved 2023-10-15.
  4. ^ "Wolfram Language Clip funcion documentation". Retrieved 2023-10-15.
  5. ^ "OpenGL 4 Reference Pages". www.khronos.org. Retrieved 2018-10-31.

clamping, graphics, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, clamping, graphics, news, newspapers, books, sch. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Clamping graphics news newspapers books scholar JSTOR December 2009 Learn how and when to remove this template message In computer science clamping or clipping is the process of limiting a value to a range between a minimum and a maximum value Unlike wrapping clamping merely moves the point to the nearest available value Y clamp X 1 3 X Y0 11 12 23 34 3In Python clamping can be defined as follows def clamp x minimum maximum if x lt minimum return minimum if x gt maximum return maximum return x This is equivalent to span class nb max span span class p span span class n minimum span span class p span span class nb min span span class p span span class n x span span class p span span class n maximum span span class p span for languages that support the functions min and max Uses editSeveral programming languages and libraries provide functions for fast and vectorized clamping In Python the pandas library offers the Series clip 1 and DataFrame clip 2 methods The NumPy library offers the clip 3 function In the Wolfram Language it is implemented as span class n Clip span span class p span span class n x span span class p span span class w span span class p span span class n minimum span span class p span span class w span span class n maximum span span class p span 4 In OpenGL the glClearColor function takes four GLfloat values which are then clamped to the range 0 1 displaystyle 0 1 nbsp 5 One of the many uses of clamping in computer graphics is the placing of a detail inside a polygon for example a bullet hole on a wall It can also be used with wrapping to create a variety of effects References edit Pandas Series clip method documentation Retrieved 2023 10 15 Pandas DataFrame clip method documentation Retrieved 2023 10 15 NumPy clip function documentation Retrieved 2023 10 15 Wolfram Language Clip funcion documentation Retrieved 2023 10 15 OpenGL 4 Reference Pages www khronos org Retrieved 2018 10 31 nbsp This computer graphics related article is a stub You can help Wikipedia by expanding it vte Retrieved from https en wikipedia org w index php title Clamping graphics amp oldid 1180837022, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.