@@ -277,40 +277,23 @@ protected float[] getAngleXY(float currentAngle){
277277 angle = 360 + angle ;
278278 }
279279 float x0 , y0 , x1 , y1 ;
280- if (angle >= 0 && angle <= 45 ) {
281- float percent = angle / 45 ;
282- x0 = width / 2f + width / 2f * percent ;
283- y0 = 0 ;
284- } else if (angle <= 90 ) {
285- float percent = (angle - 45 ) / 45 ;
286- x0 = width ;
287- y0 = height / 2f * percent ;
288- } else if (angle <= 135 ) {
289- float percent = (angle - 90 ) / 45 ;
290- x0 = width ;
291- y0 = height / 2f * percent + height / 2f ;
292- } else if (angle <= 180 ) {
293- float percent = (angle - 135 ) / 45 ;
294- x0 = width / 2f + width / 2f * (1 -percent );
295- y0 = height ;
296- } else if (angle <= 225 ) {
297- float percent = (angle - 180 ) / 45 ;
298- x0 = width / 2f - width / 2f * percent ;
299- y0 = height ;
300- } else if (angle <= 270 ) {
301- float percent = (angle - 225 ) / 45 ;
302- x0 = 0 ;
303- y0 = height - height / 2f * percent ;
304- } else if (angle <= 315 ) {
305- float percent = (angle - 270 ) / 45 ;
306- x0 = 0 ;
307- y0 = height / 2f - height / 2f * percent ;
308- } else {
309- float percent = (angle - 315 ) / 45 ;
310- x0 = width / 2f * percent ;
311- y0 = 0 ;
280+ if ((angle >= 0 && angle < 90 ) || (angle >=180 && angle < 270 )){
281+ x0 = (float ) (width /2 + Math .signum (90 - angle ) * height /2f * Math .tan (Math .toRadians (angle - (angle >= 180 ?180 :0 ))));
282+ if (x0 >= width || x0 <= 0 ){
283+ x0 = angle < 90 ?width :0 ;
284+ y0 = (float ) (height /2 - Math .signum (90 - angle ) * width /2f * Math .tan (Math .toRadians ((angle >= 180 ?270 :90 ) - angle )));
285+ }else {
286+ y0 = angle < 90 ?0 :height ;
287+ }
288+ }else {
289+ y0 = (float ) (height /2f + Math .signum (180 - angle ) * width /2f * Math .tan (Math .toRadians (angle - (angle < 180 ?90 :270 ))));
290+ if (y0 >= height || y0 <= 0 ){
291+ y0 = angle < 180 ?height :0 ;
292+ x0 = (float ) (width /2 + Math .signum (180 - angle ) * height /2f * Math .tan (Math .toRadians ((angle < 180 ?180 :360 ) - angle )));
293+ }else {
294+ x0 = angle < 180 ?width :0 ;
295+ }
312296 }
313-
314297 x1 = width - x0 ;
315298 y1 = height - y0 ;
316299
0 commit comments