440 {
441 short int octant=0;
442 if((
x.value()&(1<<16))&&(
y.value()&(1<<16))){
443 if(std::abs(
y.to_float()) < std::abs(
x.to_float())) octant = 4;
444 else octant = 5;
445 }
else if(
x.value()&(1<<16)){
446 if(std::abs(
y.to_float()) < std::abs(
x.to_float())) octant = 3;
447 else octant = 2;
448 }
else if(
y.value()&(1<<16)){
449 if(std::abs(
y.to_float()) < std::abs(
x.to_float())) octant = 7;
450 else octant = 6;
451 } else {
452 if(std::abs(
y.to_float()) < std::abs(
x.to_float())) octant = 0;
453 else octant = 1;
454 }
455
458 if(octant==0||octant==3||octant==4||octant==7){
459
460 signed_x_f =
x.abs();
461 signed_y_f =
y.abs();
462 } else {
463
464 signed_x_f =
y.abs();
465 signed_y_f =
x.abs();
466 }
467
468 const std::vector<std::string> atan2_thresholds = {
469 "000010011101100",
470 "000011000010101",
471 "000011110101100",
472 "000101000001100",
473 "000111000010010",
474 "001011010100101",
475 "011011100010101"};
476 unsigned int flag = 0;
477 for(size_t j=0;j<atan2_thresholds.size(); ++j){
478 auto thresh = TSU::L1TopoDataTypes<15,10>(atan2_thresholds.at(j));
480 if(signed_x_f.to_float() >
yy.to_float())
flag = (
flag | (1<<j));
481 }
482 unsigned int octant_fine = 0;
483 if(flag==0) octant_fine = 7;
484 else if(flag==1) octant_fine = 6;
485 else if(flag==3) octant_fine = 5;
486 else if(flag==7) octant_fine = 4;
487 else if(flag==15) octant_fine = 3;
488 else if(flag==31) octant_fine = 2;
489 else if(flag==63) octant_fine = 1;
490 else if(flag==127) octant_fine = 0;
491
492 unsigned int octant_fine2 = 0;
493 if(flag==0) octant_fine2 = 0;
494 else if(flag==1) octant_fine2 = 1;
495 else if(flag==3) octant_fine2 = 2;
496 else if(flag==7) octant_fine2 = 3;
497 else if(flag==15) octant_fine2 = 4;
498 else if(flag==31) octant_fine2 = 5;
499 else if(flag==63) octant_fine2 = 6;
500 else if(flag==127) octant_fine2 = 7;
501
502 int intphi = octant << 3;
503 if(octant==0||octant==2||octant==4||octant==6){
504 intphi |= octant_fine;
505 } else {
506 intphi |= octant_fine2;
507 }
508
509 return intphi;
510}