Advertisement
575

7 - hit_xy

575
Apr 22nd, 2023
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.72 KB | None | 0 0
  1. #pragma once
  2.  
  3. #ifndef HITXY_H
  4. #define HITXY_H
  5.  
  6. #include <vector>
  7. #include <random>
  8. #include <chrono>
  9. #include <cmath>
  10. #include <numbers>
  11. #include "file_structs.h"
  12. #include "functions.h"
  13.  
  14.  
  15. double XYDistance(auto T1, auto T2) {
  16.     return std::sqrt(std::pow(T1.x - T2.x, 2) + std::pow(T1.y - T2.y, 2));
  17. }
  18.  
  19. /*
  20. res interpretation:
  21. 0   ->  hit none
  22. 1   ->  hit body
  23. 2   ->  hit wings
  24. 3   ->  hit empennage
  25. 4   ->  hit cam
  26. 5   ->  hit armament
  27. 6   ->  hit navigation
  28. 7   ->  hit flaps
  29. 8   ->  hit elevator
  30. 9   ->  hit engine
  31. 10  ->  hit propeller
  32. 11  ->  hit fuel tank
  33. */
  34.  
  35. unsigned HitTargetElevUpperXY(target_data T, coordinates point) {
  36.     unsigned res = 0;
  37.     std::vector <coordinates> polygon_vertices;
  38.     coordinates temp;
  39.     bool is_hit;
  40.  
  41.     temp.x = -4.1;
  42.     temp.y = 2.01;
  43.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  44.     temp.x += T.coord_n_obj.x;
  45.     temp.y += T.coord_n_obj.y;
  46.     polygon_vertices.push_back(temp);
  47.    
  48.     temp.x = -4.1;
  49.     temp.y = 0.0;
  50.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  51.     temp.x += T.coord_n_obj.x;
  52.     temp.y += T.coord_n_obj.y;
  53.     polygon_vertices.push_back(temp);
  54.  
  55.     temp.x = -3.9;
  56.     temp.y = 0.0;
  57.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  58.     temp.x += T.coord_n_obj.x;
  59.     temp.y += T.coord_n_obj.y;
  60.     polygon_vertices.push_back(temp);
  61.  
  62.     temp.x = -3.9;
  63.     temp.y = 2.01;
  64.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  65.     temp.x += T.coord_n_obj.x;
  66.     temp.y += T.coord_n_obj.y;
  67.     polygon_vertices.push_back(temp);
  68.  
  69.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  70.  
  71.     if (is_hit)
  72.         res = 8; //hit elevator
  73.  
  74.     return res;
  75. }
  76.  
  77. unsigned HitTargetEmpennageXYupper(target_data T, coordinates point) {
  78.     unsigned res = 0;
  79.     std::vector <coordinates> polygon_vertices;
  80.     coordinates temp;
  81.     bool is_hit;
  82.  
  83.     temp.x = -3.0;
  84.     temp.y = 0.0;
  85.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  86.     temp.x += T.coord_n_obj.x;
  87.     temp.y += T.coord_n_obj.y;
  88.     polygon_vertices.push_back(temp);
  89.    
  90.     temp.x = -3.6;
  91.     temp.y = 2.01;
  92.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  93.     temp.x += T.coord_n_obj.x;
  94.     temp.y += T.coord_n_obj.y;
  95.     polygon_vertices.push_back(temp);
  96.  
  97.     temp.x = -4.1;
  98.     temp.y = 2.01;
  99.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  100.     temp.x += T.coord_n_obj.x;
  101.     temp.y += T.coord_n_obj.y;
  102.     polygon_vertices.push_back(temp);
  103.  
  104.     temp.x = -4.1;
  105.     temp.y = 0.0;
  106.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  107.     temp.x += T.coord_n_obj.x;
  108.     temp.y += T.coord_n_obj.y;
  109.     polygon_vertices.push_back(temp);
  110.  
  111.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  112.  
  113.     if (is_hit) {
  114.         res = HitTargetElevUpperXY(T, point);
  115.  
  116.         if (!res)
  117.             res = 3; //hit empennage
  118.     }
  119.  
  120.     return res;
  121. }
  122.  
  123. unsigned HitTargetElevLowerXY(target_data T, coordinates point) {
  124.     unsigned res = 0;
  125.     std::vector <coordinates> polygon_vertices;
  126.     coordinates temp;
  127.     bool is_hit;
  128.  
  129.     temp.x = -4.1;
  130.     temp.y = -0.49;
  131.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  132.     temp.x += T.coord_n_obj.x;
  133.     temp.y += T.coord_n_obj.y;
  134.     polygon_vertices.push_back(temp);
  135.  
  136.     temp.x = -4.1;
  137.     temp.y = -1.6;
  138.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  139.     temp.x += T.coord_n_obj.x;
  140.     temp.y += T.coord_n_obj.y;
  141.     polygon_vertices.push_back(temp);
  142.  
  143.     temp.x = -3.9;
  144.     temp.y = -1.6;
  145.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  146.     temp.x += T.coord_n_obj.x;
  147.     temp.y += T.coord_n_obj.y;
  148.     polygon_vertices.push_back(temp);
  149.  
  150.     temp.x = -3.9;
  151.     temp.y = -0.49;
  152.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  153.     temp.x += T.coord_n_obj.x;
  154.     temp.y += T.coord_n_obj.y;
  155.     polygon_vertices.push_back(temp);
  156.  
  157.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  158.  
  159.     if (is_hit)
  160.         res = 8; //hit elevator
  161.  
  162.     return res;
  163. }
  164.  
  165. unsigned HitTargetEmpennageXYlower(target_data T, coordinates point) {
  166.     unsigned res = 0;
  167.     std::vector <coordinates> polygon_vertices;
  168.     coordinates temp;
  169.     bool is_hit;
  170.  
  171.     temp.x = -3.0;
  172.     temp.y = -0.49;
  173.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  174.     temp.x += T.coord_n_obj.x;
  175.     temp.y += T.coord_n_obj.y;
  176.     polygon_vertices.push_back(temp);
  177.    
  178.     temp.x = -3.6;
  179.     temp.y = -1.6;
  180.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  181.     temp.x += T.coord_n_obj.x;
  182.     temp.y += T.coord_n_obj.y;
  183.     polygon_vertices.push_back(temp);
  184.  
  185.     temp.x = -4.1;
  186.     temp.y = -1.6;
  187.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  188.     temp.x += T.coord_n_obj.x;
  189.     temp.y += T.coord_n_obj.y;
  190.     polygon_vertices.push_back(temp);
  191.  
  192.     temp.x = -4.1;
  193.     temp.y = -0.49;
  194.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  195.     temp.x += T.coord_n_obj.x;
  196.     temp.y += T.coord_n_obj.y;
  197.     polygon_vertices.push_back(temp);
  198.  
  199.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  200.    
  201.     if (is_hit) {
  202.         res = HitTargetElevLowerXY(T, point);
  203.  
  204.         if (!res)
  205.             res = 3; //hit empennage
  206.     }
  207.  
  208.     return res;
  209. }
  210.  
  211. unsigned HitTargetPropXY(target_data T, coordinates point) {
  212.     unsigned res = 0;
  213.     std::vector <coordinates> polygon_vertices;
  214.     coordinates temp;
  215.     bool is_hit;
  216.  
  217.     temp.x = -4.98;
  218.     temp.y = -1.247;
  219.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  220.     temp.x += T.coord_n_obj.x;
  221.     temp.y += T.coord_n_obj.y;
  222.     polygon_vertices.push_back(temp);
  223.    
  224.     temp.x = -5.02;
  225.     temp.y = -1.247;
  226.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  227.     temp.x += T.coord_n_obj.x;
  228.     temp.y += T.coord_n_obj.y;
  229.     polygon_vertices.push_back(temp);
  230.  
  231.     temp.x = -5.02;
  232.     temp.y = 1.557;
  233.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  234.     temp.x += T.coord_n_obj.x;
  235.     temp.y += T.coord_n_obj.y;
  236.     polygon_vertices.push_back(temp);
  237.  
  238.     temp.x = -4.98;
  239.     temp.y = 1.557;
  240.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  241.     temp.x += T.coord_n_obj.x;
  242.     temp.y += T.coord_n_obj.y;
  243.     polygon_vertices.push_back(temp);
  244.  
  245.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  246.  
  247.     if (is_hit)
  248.         res = 10; //hit propeller
  249.  
  250.     return res;
  251. }
  252.  
  253. unsigned HitTargetEngineEmpPropXY(target_data T, coordinates point) {
  254.     unsigned res = 0;
  255.     std::vector <coordinates> polygon_vertices;
  256.     coordinates temp;
  257.     bool is_hit;
  258.  
  259.     temp.x = -2.9;
  260.     temp.y = -0.49;
  261.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  262.     temp.x += T.coord_n_obj.x;
  263.     temp.y += T.coord_n_obj.y;
  264.     polygon_vertices.push_back(temp); //1
  265.    
  266.     temp.x = -4.35;
  267.     temp.y = -0.49;
  268.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  269.     temp.x += T.coord_n_obj.x;
  270.     temp.y += T.coord_n_obj.y;
  271.     polygon_vertices.push_back(temp); //2
  272.  
  273.     temp.x = -5.4;
  274.     temp.y = 0.01;
  275.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  276.     temp.x += T.coord_n_obj.x;
  277.     temp.y += T.coord_n_obj.y;
  278.     polygon_vertices.push_back(temp); //3
  279.  
  280.     temp.x = -5.5;
  281.     temp.y = 0.155;
  282.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  283.     temp.x += T.coord_n_obj.x;
  284.     temp.y += T.coord_n_obj.y;
  285.     polygon_vertices.push_back(temp); //4
  286.  
  287.     temp.x = -5.4;
  288.     temp.y = 0.3;
  289.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  290.     temp.x += T.coord_n_obj.x;
  291.     temp.y += T.coord_n_obj.y;
  292.     polygon_vertices.push_back(temp); //5
  293.  
  294.     temp.x = -4.35;
  295.     temp.y = 0.8;
  296.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  297.     temp.x += T.coord_n_obj.x;
  298.     temp.y += T.coord_n_obj.y;
  299.     polygon_vertices.push_back(temp); //6
  300.  
  301.     temp.x = -4.2;
  302.     temp.y = 0.8;
  303.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  304.     temp.x += T.coord_n_obj.x;
  305.     temp.y += T.coord_n_obj.y;
  306.     polygon_vertices.push_back(temp); //7
  307.  
  308.     temp.x = -4.1;
  309.     temp.y = 0.9;
  310.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  311.     temp.x += T.coord_n_obj.x;
  312.     temp.y += T.coord_n_obj.y;
  313.     polygon_vertices.push_back(temp); //8
  314.  
  315.     temp.x = -3.269;
  316.     temp.y = 0.9;
  317.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  318.     temp.x += T.coord_n_obj.x;
  319.     temp.y += T.coord_n_obj.y;
  320.     polygon_vertices.push_back(temp); //9
  321.  
  322.     temp.x = -2.4;
  323.     temp.y = 0.8;
  324.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  325.     temp.x += T.coord_n_obj.x;
  326.     temp.y += T.coord_n_obj.y;
  327.     polygon_vertices.push_back(temp); //10
  328.  
  329.     temp.x = -2.4;
  330.     temp.y = 0.6;
  331.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  332.     temp.x += T.coord_n_obj.x;
  333.     temp.y += T.coord_n_obj.y;
  334.     polygon_vertices.push_back(temp); //11
  335.  
  336.     temp.x = -2.5;
  337.     temp.y = 0.49;
  338.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  339.     temp.x += T.coord_n_obj.x;
  340.     temp.y += T.coord_n_obj.y;
  341.     polygon_vertices.push_back(temp); //12
  342.  
  343.     temp.x = -2.9;
  344.     temp.y = 0.0;
  345.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  346.     temp.x += T.coord_n_obj.x;
  347.     temp.y += T.coord_n_obj.y;
  348.     polygon_vertices.push_back(temp); //13
  349.  
  350.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  351.  
  352.     if (is_hit) {
  353.         res = HitTargetEmpennageXYupper(T, point);
  354.  
  355.         if (!res)
  356.             res = HitTargetPropXY(T, point);
  357.  
  358.         if (!res)
  359.             res = 9; //hit engine
  360.     }
  361.  
  362.     return res;
  363. }
  364.  
  365. unsigned HitTargetFuelTankXY(target_data T, coordinates point) {
  366.     unsigned res = 0;
  367.     std::vector <coordinates> polygon_vertices;
  368.     coordinates temp;
  369.     bool is_hit;
  370.  
  371.     temp.x = -1.0;
  372.     temp.y = -0.2;
  373.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  374.     temp.x += T.coord_n_obj.x;
  375.     temp.y += T.coord_n_obj.y;
  376.     polygon_vertices.push_back(temp);
  377.    
  378.     temp.x = -2.5;
  379.     temp.y = -0.2;
  380.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  381.     temp.x += T.coord_n_obj.x;
  382.     temp.y += T.coord_n_obj.y;
  383.     polygon_vertices.push_back(temp);
  384.  
  385.     temp.x = -2.5;
  386.     temp.y = 0.2;
  387.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  388.     temp.x += T.coord_n_obj.x;
  389.     temp.y += T.coord_n_obj.y;
  390.     polygon_vertices.push_back(temp);
  391.  
  392.     temp.x = -1.0;
  393.     temp.y = 0.2;
  394.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  395.     temp.x += T.coord_n_obj.x;
  396.     temp.y += T.coord_n_obj.y;
  397.     polygon_vertices.push_back(temp);
  398.  
  399.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  400.  
  401.     if (is_hit)
  402.         res = 11; //hit fuel tank
  403.  
  404.     return res;
  405. }
  406.  
  407. unsigned HitTargetNaviXY(target_data T, coordinates point) {
  408.     unsigned res = 0;
  409.     std::vector <coordinates> polygon_vertices;
  410.     coordinates temp;
  411.     bool is_hit;
  412.  
  413.     temp.x = 1.49;
  414.     temp.y = 0.49;
  415.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  416.     temp.x += T.coord_n_obj.x;
  417.     temp.y += T.coord_n_obj.y;
  418.     polygon_vertices.push_back(temp); //1
  419.    
  420.     temp.x = 3.0;
  421.     temp.y = 0.9;
  422.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  423.     temp.x += T.coord_n_obj.x;
  424.     temp.y += T.coord_n_obj.y;
  425.     polygon_vertices.push_back(temp); //2
  426.  
  427.     temp.x = 4.0;
  428.     temp.y = 0.9;
  429.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  430.     temp.x += T.coord_n_obj.x;
  431.     temp.y += T.coord_n_obj.y;
  432.     polygon_vertices.push_back(temp); //3
  433.  
  434.     temp.x = 5.295;
  435.     temp.y = -0.3;
  436.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  437.     temp.x += T.coord_n_obj.x;
  438.     temp.y += T.coord_n_obj.y;
  439.     polygon_vertices.push_back(temp); //4
  440.  
  441.     temp.x = 2.0;
  442.     temp.y = -0.3;
  443.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  444.     temp.x += T.coord_n_obj.x;
  445.     temp.y += T.coord_n_obj.y;
  446.     polygon_vertices.push_back(temp); //5
  447.  
  448.     temp.x = 1.4;
  449.     temp.y = 0.35;
  450.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  451.     temp.x += T.coord_n_obj.x;
  452.     temp.y += T.coord_n_obj.y;
  453.     polygon_vertices.push_back(temp); //6
  454.  
  455.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  456.  
  457.     if (is_hit)
  458.         res = 6; //hit navigation
  459.  
  460.     return res;
  461. }
  462.  
  463. unsigned HitTargetRocketXY(target_data T, coordinates point) {
  464.     unsigned res = 0;
  465.     std::vector <coordinates> polygon_vertices;
  466.     coordinates temp;
  467.     bool is_hit;
  468.  
  469.     temp.x = -1.0;
  470.     temp.y = -0.075;
  471.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  472.     temp.x += T.coord_n_obj.x;
  473.     temp.y += T.coord_n_obj.y;
  474.     polygon_vertices.push_back(temp);
  475.    
  476.     temp.x = 1.0;
  477.     temp.y = -0.075;
  478.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  479.     temp.x += T.coord_n_obj.x;
  480.     temp.y += T.coord_n_obj.y;
  481.     polygon_vertices.push_back(temp);
  482.  
  483.     temp.x = 1.275;
  484.     temp.y = -0.275;
  485.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  486.     temp.x += T.coord_n_obj.x;
  487.     temp.y += T.coord_n_obj.y;
  488.     polygon_vertices.push_back(temp);
  489.  
  490.     temp.x = 1.0;
  491.     temp.y = -0.475;
  492.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  493.     temp.x += T.coord_n_obj.x;
  494.     temp.y += T.coord_n_obj.y;
  495.     polygon_vertices.push_back(temp);
  496.  
  497.     temp.x = -1.0;
  498.     temp.y = -0.475;
  499.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  500.     temp.x += T.coord_n_obj.x;
  501.     temp.y += T.coord_n_obj.y;
  502.     polygon_vertices.push_back(temp);
  503.  
  504.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  505.  
  506.     if (is_hit)
  507.         res = 5; //hit armament
  508.  
  509.     return res;
  510. }
  511.  
  512. unsigned HitTargetWingsXY(target_data T, coordinates point) {
  513.     unsigned res = 0;
  514.     std::vector <coordinates> polygon_vertices;
  515.     coordinates temp;
  516.     bool is_hit;
  517.  
  518.     temp.x = 0.825;
  519.     temp.y = 0.075;
  520.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  521.     temp.x += T.coord_n_obj.x;
  522.     temp.y += T.coord_n_obj.y;
  523.     polygon_vertices.push_back(temp);
  524.    
  525.     temp.x = 0.825;
  526.     temp.y = -0.075;
  527.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  528.     temp.x += T.coord_n_obj.x;
  529.     temp.y += T.coord_n_obj.y;
  530.     polygon_vertices.push_back(temp);
  531.  
  532.     temp.x = -0.825;
  533.     temp.y = -0.075;
  534.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  535.     temp.x += T.coord_n_obj.x;
  536.     temp.y += T.coord_n_obj.y;
  537.     polygon_vertices.push_back(temp);
  538.  
  539.     temp.x = -0.825;
  540.     temp.y = 0.075;
  541.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  542.     temp.x += T.coord_n_obj.x;
  543.     temp.y += T.coord_n_obj.y;
  544.     polygon_vertices.push_back(temp);
  545.  
  546.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  547.  
  548.     if (is_hit)
  549.         res = 2; //hit wings
  550.  
  551.     return res;
  552. }
  553.  
  554. unsigned HitTargetBodyXY(target_data T, coordinates point) {
  555.     unsigned res = 0;
  556.     std::vector <coordinates> polygon_vertices;
  557.     coordinates temp;
  558.     bool is_hit;
  559.  
  560.     temp.x = 1.49;
  561.     temp.y = 0.49;
  562.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  563.     temp.x += T.coord_n_obj.x;
  564.     temp.y += T.coord_n_obj.y;
  565.     polygon_vertices.push_back(temp); //1
  566.    
  567.     temp.x = 3.0;
  568.     temp.y = 0.9;
  569.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  570.     temp.x += T.coord_n_obj.x;
  571.     temp.y += T.coord_n_obj.y;
  572.     polygon_vertices.push_back(temp); //2
  573.  
  574.     temp.x = 4.0;
  575.     temp.y = 0.9;
  576.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  577.     temp.x += T.coord_n_obj.x;
  578.     temp.y += T.coord_n_obj.y;
  579.     polygon_vertices.push_back(temp); //3
  580.  
  581.     temp.x = 5.5;
  582.     temp.y = -0.49;
  583.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  584.     temp.x += T.coord_n_obj.x;
  585.     temp.y += T.coord_n_obj.y;
  586.     polygon_vertices.push_back(temp); //4
  587.  
  588.     temp.x = 4.95;
  589.     temp.y = -0.75;
  590.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  591.     temp.x += T.coord_n_obj.x;
  592.     temp.y += T.coord_n_obj.y;
  593.     polygon_vertices.push_back(temp); //5
  594.  
  595.     temp.x = 4.09;
  596.     temp.y = -0.75;
  597.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  598.     temp.x += T.coord_n_obj.x;
  599.     temp.y += T.coord_n_obj.y;
  600.     polygon_vertices.push_back(temp); //6
  601.  
  602.     temp.x = 1.49;
  603.     temp.y = -0.49;
  604.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  605.     temp.x += T.coord_n_obj.x;
  606.     temp.y += T.coord_n_obj.y;
  607.     polygon_vertices.push_back(temp); //7
  608.  
  609.     temp.x = -4.35;
  610.     temp.y = -0.49;
  611.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  612.     temp.x += T.coord_n_obj.x;
  613.     temp.y += T.coord_n_obj.y;
  614.     polygon_vertices.push_back(temp); //8
  615.  
  616.     temp.x = -5.4;
  617.     temp.y = 0.01;
  618.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  619.     temp.x += T.coord_n_obj.x;
  620.     temp.y += T.coord_n_obj.y;
  621.     polygon_vertices.push_back(temp); //9
  622.  
  623.     temp.x = -5.5;
  624.     temp.y = 0.155;
  625.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  626.     temp.x += T.coord_n_obj.x;
  627.     temp.y += T.coord_n_obj.y;
  628.     polygon_vertices.push_back(temp); //10
  629.  
  630.     temp.x = -5.4;
  631.     temp.y = 0.3;
  632.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  633.     temp.x += T.coord_n_obj.x;
  634.     temp.y += T.coord_n_obj.y;
  635.     polygon_vertices.push_back(temp); //11
  636.  
  637.     temp.x = -4.35;
  638.     temp.y = 0.8;
  639.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  640.     temp.x += T.coord_n_obj.x;
  641.     temp.y += T.coord_n_obj.y;
  642.     polygon_vertices.push_back(temp); //12
  643.  
  644.     temp.x = -4.2;
  645.     temp.y = 0.8;
  646.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  647.     temp.x += T.coord_n_obj.x;
  648.     temp.y += T.coord_n_obj.y;
  649.     polygon_vertices.push_back(temp); //13
  650.  
  651.     temp.x = -4.1;
  652.     temp.y = 0.9;
  653.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  654.     temp.x += T.coord_n_obj.x;
  655.     temp.y += T.coord_n_obj.y;
  656.     polygon_vertices.push_back(temp); //14
  657.  
  658.     temp.x = -3.269;
  659.     temp.y = 0.9;
  660.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  661.     temp.x += T.coord_n_obj.x;
  662.     temp.y += T.coord_n_obj.y;
  663.     polygon_vertices.push_back(temp); //15
  664.  
  665.     temp.x = -2.4;
  666.     temp.y = 0.8;
  667.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  668.     temp.x += T.coord_n_obj.x;
  669.     temp.y += T.coord_n_obj.y;
  670.     polygon_vertices.push_back(temp); //16
  671.  
  672.     temp.x = -2.4;
  673.     temp.y = 0.6;
  674.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  675.     temp.x += T.coord_n_obj.x;
  676.     temp.y += T.coord_n_obj.y;
  677.     polygon_vertices.push_back(temp); //17
  678.  
  679.     temp.x = -2.5;
  680.     temp.y = 0.49;
  681.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  682.     temp.x += T.coord_n_obj.x;
  683.     temp.y += T.coord_n_obj.y;
  684.     polygon_vertices.push_back(temp); //18
  685.  
  686.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  687.  
  688.     if (is_hit) {
  689.         res = HitTargetEngineEmpPropXY(T, point);
  690.  
  691.         if (!res)
  692.             res = HitTargetFuelTankXY(T, point);
  693.  
  694.         if (!res)
  695.             res = HitTargetNaviXY(T, point);
  696.  
  697.         if (!res)
  698.             res = HitTargetRocketXY(T, point);
  699.  
  700.         if (!res)
  701.             res = HitTargetWingsXY(T, point);
  702.  
  703.         if (!res)
  704.             res = 1; //hit body
  705.     }
  706.  
  707.     return res;
  708. }
  709.  
  710. unsigned HitTargetCamXY(target_data T, coordinates point) {
  711.     unsigned res = 0;
  712.     std::vector <coordinates> polygon_vertices;
  713.     coordinates temp;
  714.     bool is_hit;
  715.  
  716.     temp.x = 4.3;
  717.     temp.y = -0.75;
  718.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  719.     temp.x += T.coord_n_obj.x;
  720.     temp.y += T.coord_n_obj.y;
  721.     polygon_vertices.push_back(temp);
  722.  
  723.     temp.x = 4.7;
  724.     temp.y = -0.75;
  725.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  726.     temp.x += T.coord_n_obj.x;
  727.     temp.y += T.coord_n_obj.y;
  728.     polygon_vertices.push_back(temp);
  729.  
  730.     temp.x = 4.7;
  731.     temp.y = -0.95;
  732.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  733.     temp.x += T.coord_n_obj.x;
  734.     temp.y += T.coord_n_obj.y;
  735.     polygon_vertices.push_back(temp);
  736.  
  737.     temp.x = 4.3;
  738.     temp.y = -0.95;
  739.     temp = MakeRotation(temp, 0.0, T.pitch_obj);
  740.     temp.x += T.coord_n_obj.x;
  741.     temp.y += T.coord_n_obj.y;
  742.     polygon_vertices.push_back(temp);
  743.  
  744.     is_hit = CrossingNumberAlgoXY(polygon_vertices, point);
  745.  
  746.     if (is_hit) {
  747.         coordinates cam_center;
  748.         cam_center.x = 4.5;
  749.         cam_center.y = -0.75;
  750.         cam_center = MakeRotation(cam_center, 0.0, T.pitch_obj);
  751.         cam_center.x += T.coord_n_obj.x;
  752.         cam_center.y += T.coord_n_obj.y;
  753.        
  754.         if (XYDistance(point, cam_center) < 0.2)
  755.             res = 4; //hit cam
  756.        
  757.     }
  758.        
  759.  
  760.     return res;
  761. }
  762.  
  763. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement