getCoordinates method
Converts the pixel coordinates (pixelX
, pixelY
) to the manim coordinates
The result is returned as a Vector3, but used as a vector2 containing
the coordinates x and y of the corresponding point
@param pixelX
from 0 to pixel width
@param pixelY
from 0 to pixel height
Implementation
Vector3 getCoordinates(double pixelX, double pixelY) {
// map pixelX which can be between 0 and pixelWidth
// to between -frameWidth / 2 and frameWidth / 2
var sx = mapValue(pixelX, 0, camera.pixelWidth, -camera.frameWidth / 2,
camera.frameWidth / 2);
// same as the x coordinate except that the screen coordinates
// and the manim coordinates have an inverted y axis
var sy = mapValue(pixelY, camera.pixelHeight, 0, -camera.frameHeight / 2,
camera.frameHeight / 2);
return Vector3(sx, sy, 0) + camera.frameCenter;
}