astroimsim-geometry 0.1.20

Geometry package for astroimsim
Documentation

use plotpy::Plot;
use astroimsim_geometry::coordinate_system::Coordinates::RELATIVE;
use astroimsim_geometry::coordinate_system::{CoordinateSystem, Coordinates};
use astroimsim_geometry::grid2d::GRID2D;
use astroimsim_geometry::grid2d::PlotPoint::Given;
use astroimsim_geometry::points::Point;
use astroimsim_geometry::prelude::PlotPoint;
use crate::coordinate_system::Coordinates::ABSOLUTE;
use crate::projection_test::test_project;

pub mod coordinate_system;
pub mod grid1d;
pub mod grid2d;
pub mod points;
mod projection_test;

fn main() {
    let strange_coordinates = CoordinateSystem::new((1.0,-0.6),(0.3,1.0),(6.8,1.7),"strange");

    let coords2 = strange_coordinates;
    let mut plot = Plot::new();


    let point_1 = Point::new(4.5,-1.3,Coordinates::RELATIVE(coords2.clone()));
    let aabs =  point_1.to_absolute();
   // println!("original point{:?}", point_1);
    //println!("converted {:?}",aabs);
    //println!("back to relative {:?}", coords2.point_from_absolute(aabs));
   // let point_2 = Point::new(1.1,3.0,Coordinates::RELATIVE(coords2.clone()));
   // let point_3 = Point::new(2.7,-2.5,Coordinates::RELATIVE(coords2.clone()));
   // let point_4 = Point::new(-4.5,-2.5,Coordinates::RELATIVE(coords2.clone()));


    let grid2 = GRID2D::new_empty((10,10), (2.0,2.0), (0.0,0.0),0.001, Coordinates::RELATIVE(coords2.clone()));
    //coords2.plot(&mut plot, "purple");
    grid2.plot_outline(&mut plot, "purple");
    coords2.plot(&mut plot, "pink");

    grid2.plot_points(&mut plot, PlotPoint::Given(point_1));
   // grid2.plot_points(&mut plot, PlotPoint::Given(point_2));
    //grid2.plot_points(&mut plot, PlotPoint::Given(point_3));
   // grid2.plot_points(&mut plot, PlotPoint::Given(point_4));

    plot.set_title("Regular Grid on a Coordinate System");
    //plot.legend();
    plot.show("tests/grid2_points_test").expect("could not save figure");




    /*

    let mut plot = Plot::new();
    let coords = CoordinateSystem::new((7.0,-6.2),(-0.4,4.0),(0.0,0.0), "test_1");
    let grid = GRID2D::new_empty((9,9),(1.0,1.0),(0.0,0.0), 0.0001,RELATIVE(coords.clone()));
   // println!("rid number 50 {:?}", grid.locate(50).to_absolute().values());
    let point_2 = Point::new(1.5,2.2,Coordinates::RELATIVE(coords.clone()));
   // println!("{:?}", point_2);
    let point = Point::new(2.6, -4.2,Coordinates::ABSOLUTE);
   // println!("point from absolute{:?}",CoordinateSystem::point_from_absolute(&coords.clone(),point));
   // println!("{:?}", point_2.to_absolute());
    //println!("{:?}", point_2.convert(&RELATIVE(coords.clone())));

   // println!("{:?}",grid.fit_grid(&point_2));


    grid.plot_points(&mut plot, Given(point_2));
    coords.plot(&mut plot,"green");
    plot.legend();
    plot.save("test");
    plot.show("slefj").unwrap();



    /*
let grid = GRID2D::new_from_width((9000,9000),(1.0,1.0), (0.0,0.0), 0.01,RELATIVE(coords.clone()));
println!("{:?}",grid.locate(grid.num_points-1));


let grid = GRID2D::new_from_width((6,6),(1.0,1.0), (0.0,0.0), 0.01,RELATIVE(coords.clone()));
println!("{:?}",grid.locate(grid.num_points-1))

     */

}

pub fn norm(vect:(f64,f64))->(f64,f64){
    let norm = (vect.0.powi(2)+ vect.1.powi(2)).sqrt();
    (vect.0/norm,vect.1/norm)

     */

}