public double getAngle(int Ax、int Ay、int Bx、int By、int Cx、int Cy){ double lengthAB = Math.sqrt(Math.pow(Ax-Bx、2)+ Math.pow(Ay-By、2))、 lengthAC = Math.sqrt(Math.pow(Ax-Cx、2)+ Math.pow(Ay-Cy、2))、 lengthBC = Math.sqrt(Math.pow(Bx-Cx、2)+ Math.pow(By --Cy、2)); double cosA =(Math.pow(lengthAB、2)+ Math.pow(lengthAC、2)-Math.pow(lengthBC、2))/ (2 * lengthAB * lengthAC); double angleA = Math.round(Math.acos(cosA)* 180 / Math.PI); 戻り角度A; } public float distance(float x、float y、float sx、float sy){ float dx = x-sx; float dy = y-彼女; return(float)Math.sqrt(dx * dx + dy * dy); } private void drawArrow(ペイントペイント、キャンバスキャンバス、float from_x、float from_y、float to_x、float to_y、float arrow_x、float arrow_y、float angle) {{ フロートanglerad、radius、lineangle; //他の外観のために変更する値*他のサイズの矢印のためにこれらを変更する* radius = distance(to_x、to_y、arrow_x、arrow_y); ; //いくつかの角度計算 anglerad =(float)(PI * angle * 2 / 180.0f); lineangle =(float)(atan2(to_y-from_y、to_x-from_x)); // tha行 canvas.drawLine(from_x、from_y、to_x、to_y、paint); // canvas.drawLine(to_x、to_y、(float)(to_x-radius * cos(lineangle-(anglerad / 2.0)))、 //(float)(to_y-radius * sin(lineangle-(anglerad / 2.0)))、paint); // // canvas.drawLine(to_x、to_y、(float)(to_x-radius * cos(lineangle +(anglerad / 2.0)))、 //(float)(to_y-radius * sin(lineangle +(anglerad / 2.0)))、paint); //三角形 パスpath = new Path(); // path.moveTo(to_x、to_y); path.lineTo((float)(to_x-radius * cos(lineangle-(anglerad / 2.0)))、 (float)(to_y-radius * sin(lineangle-(anglerad / 2.0)))); path.moveTo(to_x、to_y); path.lineTo((float)(to_x-radius * cos(lineangle +(anglerad / 2.0)))、 (float)(to_y-radius * sin(lineangle +(anglerad / 2.0)))); canvas.drawPath(path、paint); }
矢印を描く
おすすめ
転載: blog.csdn.net/jiabailong/article/details/107544414
おすすめ
ランキング