pub fn screen_to_world(&self, point: [f64; 2]) -> [f64; 2] {
        let [sx, sy] = self.screen_size;
        let [cx, cy] = self.center;
        let [x, y] = point;

        assert!(x >= 0.0 && x < sx, "x is outside screen domain coordinates");
        assert!(y >= 0.0 && y < sy, "y is outside screen domain coordinates");

        let screen_ratio = sx / sy;

        // reduce the point to world coordinates:
        //
        // `* 2.0` move to `[0, 2 * width[`
        // `x / sx` reduce to `[0, 2[`
        // `- 1.0` move to `[-1, 1[`
        // `* screen_ratio` keep the screen ratio
        // `* self.zoom` reduce to the current zoom
        // `+ cx` translate the point to the center
        let x = (x * 2.0 / sx - 1.0) * screen_ratio * self.zoom + cx;
        let y = (y * 2.0 / sy - 1.0) * self.zoom + cy;

        [x, y]
    }
/// Transforms the point in screen coordinates in a point in world coordinates,
/// taking the screen data and the zoom into account.
///
/// `point` is the point in screen coordinates (`[0, width[`).
Transforms the point in screen coordinates in a point in world coordinates,
taking the screen data and the zoom into account.

`point` is the point in screen coordinates (`[0, width[`).
Transforms the point in screen coordinates in a point in world coordinates taking the screen data and the zoom into account . ` point ` is the point in screen coordinates ( ` [ 0 width [ ` ) .
pub fn screen_to_world(&self, point: [f64; 2]) -> [f64; 2] {
        let [sx, sy] = self.screen_size;
        let [cx, cy] = self.center;
        let [x, y] = point;
        assert!(x >= 0.0 && x < sx, "x is outside screen domain coordinates");
        assert!(y >= 0.0 && y < sy, "y is outside screen domain coordinates");
        let screen_ratio = sx / sy;
        // reduce the point to world coordinates:
        //
        // `* 2.0` move to `[0, 2 * width[`
        // `x / sx` reduce to `[0, 2[`
        // `- 1.0` move to `[-1, 1[`
        // `* screen_ratio` keep the screen ratio
        // `* self.zoom` reduce to the current zoom
        // `+ cx` translate the point to the center
        let x = (x * 2.0 / sx - 1.0) * screen_ratio * self.zoom + cx;
        let y = (y * 2.0 / sy - 1.0) * self.zoom + cy;
        [x, y]
    }
pub fn screen_to_world ( & self , point : [ f64 ; 2 ] ) -> [ f64 ; 2 ] { let [ sx , sy ] = self . screen_size ; let [ cx , cy ] = self . center ; let [ x , y ] = point ; assert ! ( x 0.0 x sx " " ) ; assert ! ( y 0.0 y sy " " ) ; let screen_ratio = sx / sy ; // reduce the point to world coordinates: // // `* 2.0` move to `[0, 2 * width[` // `x / sx` reduce to `[0, 2[` // `- 1.0` move to `[-1, 1[` // `* screen_ratio` keep the screen ratio // `* self.zoom` reduce to the current zoom // `+ cx` translate the point to the center let x = ( x * 2.0 / sx - 1.0 ) * screen_ratio * self . zoom + cx ; let y = ( y * 2.0 / sy - 1.0 ) * self . zoom + cy ; [ x , y ] }
Transforms the point in screen coordinates in a point in world coordinates,
taking the screen data and the zoom into account.
Transforms the point in screen coordinates in a point in world coordinates taking the screen data and the zoom into account .
&self
point
[f64; 2]
&self
point
[f64; 2]