| 99 | } |
| 100 | |
| 101 | bool LuaSTGPlus::OBBCircleHitTest(fcyVec2 P1, fcyVec2 Size, float Angle, |
| 102 | fcyVec2 P2, float R) |
| 103 | { |
| 104 | // ��������ε�4������ |
| 105 | fcyVec2 tFinalPos[4] = |
| 106 | { |
| 107 | fcyVec2(-Size.x, -Size.y), |
| 108 | fcyVec2(Size.x, -Size.y), |
| 109 | fcyVec2(Size.x, Size.y), |
| 110 | fcyVec2(-Size.x, Size.y) |
| 111 | }; |
| 112 | |
| 113 | // float tSin = sin(Angle), tCos = cos(Angle); |
| 114 | float tSin, tCos; |
| 115 | SinCos(Angle, tSin, tCos); |
| 116 | |
| 117 | // �任 |
| 118 | for (int i = 0; i<4; i++) |
| 119 | { |
| 120 | tFinalPos[i].RotationSC(tSin, tCos); |
| 121 | tFinalPos[i] += P1; |
| 122 | } |
| 123 | |
| 124 | // ������������ |
| 125 | fcyVec2 tAxis[2] = |
| 126 | { |
| 127 | tFinalPos[1] - tFinalPos[0], |
| 128 | tFinalPos[2] - tFinalPos[1] |
| 129 | }; |
| 130 | |
| 131 | // �᳤�� |
| 132 | float tAxisLen[2] = |
| 133 | { |
| 134 | tAxis[0].Length(), |
| 135 | tAxis[1].Length(), |
| 136 | }; |
| 137 | |
| 138 | // ������� |
| 139 | if (tAxisLen[0] != 0.f) |
| 140 | tAxis[0] /= tAxisLen[0]; |
| 141 | if (tAxisLen[1] != 0.f) |
| 142 | tAxis[1] /= tAxisLen[1]; |
| 143 | |
| 144 | // ����������IJο����������ϵ�ͶӰ |
| 145 | float tProjValue[2] = |
| 146 | { |
| 147 | ((tFinalPos[1] + tFinalPos[0]) / 2.f) * tAxis[0], |
| 148 | ((tFinalPos[2] + tFinalPos[1]) / 2.f) * tAxis[1] |
| 149 | }; |
| 150 | |
| 151 | // ����Բ�����ϵ�ͶӰ |
| 152 | float tCircleCenterProjValue[2] = |
| 153 | { |
| 154 | P2 * tAxis[0], |
| 155 | P2 * tAxis[1] |
| 156 | }; |
| 157 | |
| 158 | // ������ײ |