On 5/07/20 4:39 pm, Steven D'Aprano wrote:
Complex numbers represent points on a plane; it is very common in graphical toolkits to need to clamp an object to within some window or other region of the plane,
But graphical toolkits don't treat points as complex numbers. The question is whether there is a conventional generalisation of clamp() used in complex analysis. There isn't one that I know of.
so that you don't (e.g.) drag your object outside of the document, or position it somewhere off screen where it is impossible for the user to click on.
I wouldn't call this operation "clipping", though -- see below.
There are two standard terms for this function: clamp and clip, depending on whether you view the operation as squashing the value into a range or cutting off the bits that don't fit.
The notion of clipping in computer graphics is not really the same thing. If you're drawing a point clipped to a window, and it's outside the window, then you skip drawing it altogether, you don't move it to the boundary of the window. And if you're drawing a line that's partly inside and partly outside the window, you need to cut off the part that's outside -- but you can't do that by clamping the outside point to the window, you need to do something more complicated. Another data point: In OpenGL documentation, the operation of limiting colour values or texture coordinates to be within a certain range is called "clamping". All in all, I think "clamp" is the best term for this. -- Greg _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VLSAYZ7GSIUNT7FGN5ZV4SDXX7RAFSQC/ Code of Conduct: http://python.org/psf/codeofconduct/