반응형
public short bearingP1toP2(double P1_latitude, double P1_longitude, double P2_latitude, double P2_longitude) { // 현재 위치 : 위도나 경도는 지구 중심을 기반으로 하는 각도이기 때문에 라디안 각도로 변환한다. double Cur_Lat_radian = P1_latitude * (3.141592 / 180); double Cur_Lon_radian = P1_longitude * (3.141592 / 180); // 목표 위치 : 위도나 경도는 지구 중심을 기반으로 하는 각도이기 때문에 라디안 각도로 변환한다. double Dest_Lat_radian = P2_latitude * (3.141592 / 180); double Dest_Lon_radian = P2_longitude * (3.141592 / 180); // radian distance double radian_distance = 0; radian_distance = Math.acos(Math.sin(Cur_Lat_radian) * Math.sin(Dest_Lat_radian) + Math.cos(Cur_Lat_radian) * Math.cos(Dest_Lat_radian) * Math.cos(Cur_Lon_radian - Dest_Lon_radian)); // 목적지 이동 방향을 구한다.(현재 좌표에서 다음 좌표로 이동하기 위해서는 방향을 설정해야 한다. 라디안값이다. double radian_bearing = Math.acos((Math.sin(Dest_Lat_radian) - Math.sin(Cur_Lat_radian) * Math.cos(radian_distance)) / (Math.cos(Cur_Lat_radian) * Math.sin(radian_distance))); // acos의 인수로 주어지는 x는 360분법의 각도가 아닌 radian(호도)값이다. double true_bearing = 0; if (Math.sin(Dest_Lon_radian - Cur_Lon_radian) < 0) { true_bearing = radian_bearing * (180 / 3.141592); true_bearing = 360 - true_bearing; } else { true_bearing = radian_bearing * (180 / 3.141592); } return (short)true_bearing; }
mImaveView.setImageBitmap(rotateImage( BitmapFactory.decodeResource(getResources(),R.drawable.diablo), mDegree)); // 이미지 회전 함수 public Bitmap rotateImage(Bitmap src, float degree) { // Matrix 객체 생성 Matrix matrix = new Matrix(); // 회전 각도 셋팅 matrix.postRotate(degree); // 이미지와 Matrix 를 셋팅해서 Bitmap 객체 생성 return Bitmap.createBitmap(src, 0, 0, src.getWidth(),src.getHeight(), matrix, true); } 출처: http://mainia.tistory.com/2613 [녹두장군 - 상상을 현실로]
mImaveView = (ImageView) findViewById(R.id.imgRotate); mImaveView.setImageBitmap(rotateImage( BitmapFactory.decodeResource(getResources(), R.drawable.diablo), mDegree)); 출처: http://mainia.tistory.com/2613 [녹두장군 - 상상을 현실로]
반응형
'Android' 카테고리의 다른 글
USB디버깅] APK만 있을 때 로그 보기 (adb, logcat) (0) | 2021.12.23 |
---|---|
Android SQLite 사용 방법 및 소스코드 (0) | 2016.10.30 |