Normalise
Working with normalised geometric references can be useful for the same reason as normalised plain numbers. For example, perhaps you have a stream of Points from a computer vision library for the location of a detected nose. This position might be in camera coordinates, meaning that 0,0 represents the top-left corner of a frame from the camera. The max width and height will be determined by the resolution setting of the camera/library.
You don’t want to have to think about the scale of camera coordinates throughout the code, and importantly, it may change if you opt for a different camera resolution. Normalising to 0,0 - 1,1 may be the answer:
You might also want to verify the points don’t exceed 0..1, using Numbers.clamp .
This can all be a little easier with Points.normaliseByRect
Points.clamp will clamp both x and y, so our earlier example could be simplified to:
If you have a normalised point, you will likely need to map it to an absolute space at some point, for example to the dimensions of the viewport. Points.multiply can be used for this: