use bevy::math::Vec3; use laserspace::trap::laser::{self, apply_homography_matrix}; /* Compare output with the following python ```python import numpy as np import cv2 H =np.array([[ 2.47442963e+02, -7.01714050e+01, -9.71749119e+01], [ 1.02328119e+01, 1.47185254e+02, 1.96295638e+02], [-1.20921986e-03, -3.32735973e-02, 1.00000000e+00]]) points =[[1.,1.0],[2.0,2.0]] print(cv2.perspectiveTransform(np.array([points]), H)) ``` */ fn main(){ { let point = Vec3::new(1.0,1.0,1.0); let laser_h = laser::python_cv_h_into_mat3(laser::TMP_PYTHON_LASER_H); let new_point = laser_h.mul_vec3(point); println!("{} is wrong", new_point); } { let point = Vec3::new(2.0,2.0,1.0); let laser_h = laser::python_cv_h_into_mat3(laser::TMP_PYTHON_LASER_H); let new_point = laser_h.mul_vec3(point); println!("{} is also wrong", new_point); let t = [new_point[0]/new_point[2],new_point[1]/new_point[2]]; println!("{:?} but can be fixed!", t); } { let p = apply_homography_matrix(laser::python_cv_h_into_mat3(laser::TMP_PYTHON_LASER_H), &[1.,1.]); println!("{:?} this is right as well!", p); } }