public PlaPointInt fortyfive_degree_projection(PlaPointInt p_other){
  int dx=this.v_x - p_other.v_x;
  int dy=this.v_y - p_other.v_y;
  double[] dist_arr=new double[4];
  dist_arr[0]=Math.abs(dx);
  dist_arr[1]=Math.abs(dy);
  double diagonal_1=((double)dy - (double)dx) / 2;
  double diagonal_2=((double)dy + (double)dx) / 2;
  dist_arr[2]=Math.abs(diagonal_1);
  dist_arr[3]=Math.abs(diagonal_2);
  double min_dist=dist_arr[0];
  for (int i=1; i < 4; ++i) {
    if (dist_arr[i] < min_dist) {
      min_dist=dist_arr[i];
    }
  }
  PlaPointInt result;
  if (min_dist == dist_arr[0]) {
    result=new PlaPointInt(p_other.v_x,this.v_y);
  }
 else   if (min_dist == dist_arr[1]) {
    result=new PlaPointInt(this.v_x,p_other.v_y);
  }
 else   if (min_dist == dist_arr[2]) {
    int diagonal_value=(int)diagonal_2;
    result=new PlaPointInt(p_other.v_x + diagonal_value,p_other.v_y + diagonal_value);
  }
 else {
    int diagonal_value=(int)diagonal_1;
    result=new PlaPointInt(p_other.v_x - diagonal_value,p_other.v_y + diagonal_value);
  }
  return result;
}

public PlaPointInt fortyfive_degree_projection ( PlaPointInt p_other ) { int dx = this . v_x - p_other . v_x ; int dy = this . v_y - p_other . v_y ; double [ ] dist_arr = new double [ 4 ] ; dist_arr [ 0 ] = Math . abs ( dx ) ; dist_arr [ 1 ] = Math . abs ( dy ) ; double diagonal_1 = ( ( double ) dy - ( double ) dx ) / 2 ; double diagonal_2 = ( ( double ) dy + ( double ) dx ) / 2 ; dist_arr [ 2 ] = Math . abs ( diagonal_1 ) ; dist_arr [ 3 ] = Math . abs ( diagonal_2 ) ; double min_dist = dist_arr [ 0 ] ; for ( int i = 1 ; i < 4 ; ++ i ) { if ( dist_arr [ i ] < min_dist ) { min_dist = dist_arr [ i ] ; } } PlaPointInt result ; if ( min_dist == dist_arr [ 0 ] ) { result = new PlaPointInt ( p_other . v_x , this . v_y ) ; } else if ( min_dist == dist_arr [ 1 ] ) { result = new PlaPointInt ( this . v_x , p_other . v_y ) ; } else if ( min_dist == dist_arr [ 2 ] ) { int diagonal_value = ( int ) diagonal_2 ; result = new PlaPointInt ( p_other . v_x + diagonal_value , p_other . v_y + diagonal_value ) ; } else { int diagonal_value = ( int ) diagonal_1 ; result = new PlaPointInt ( p_other . v_x - diagonal_value , p_other . v_y + diagonal_value ) ; } return result ; }
calculates the nearest point to this point on an orthogonal or diagonal line through p_other ( snaps this point to on 45 degree line through p_other ) .
