UNPKG

@nestbotics/nct_frontend_common_components

Version:

A collection of reusable React components with theme management and styling utilities

25 lines (24 loc) 643 B
// src/coordinateUtils.js export var worldToImage = function worldToImage(x_w, y_w, x_origin, y_origin, resolution) { var x_i = (x_w - x_origin) / resolution; var y_i = (y_w - y_origin) / resolution; return { x_i: x_i, y_i: y_i }; }; export var scaleCoordinates = function scaleCoordinates(x_i, y_i, scale) { var x_i_scaled = x_i * scale; var y_i_scaled = y_i * scale; return { x_i_scaled: x_i_scaled, y_i_scaled: y_i_scaled }; }; export var imageToCanvas = function imageToCanvas(x_i_scaled, y_i_scaled, imageHeight) { var y_c = imageHeight - y_i_scaled; return { x_c: x_i_scaled, y_c: y_c }; };