如何画一个直径的Andr​​oid圆的 [英] How to draw a diameter of a circle in Android

查看:136
本文介绍了如何画一个直径的Andr​​oid圆的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提到的问题<一href=\"http://stackoverflow.com/questions/11549984/draw-a-circle-within-circle-at-a-distance-of-10\">Draw在10 的距离内圆的圆
这是接近我的要求。我只需要两个同心圆一个接一个的内层半径缩小到300 MTS和外层半径缩小到500 MTS内。

I referred the question Draw a circle within circle at a distance of 10 which comes close to my requirement. I just needed two concentric circles one inside the other inner one with radius scaled to 300 mts and outer one with radius scaled to 500 mts.

我已经能够绘制使用在转化米到相应的像素间距距离的变换方法,我的屏幕上的像素比例的两个圆圈。
下一步是画出圆圈内加;该行是直径。因此,他们将通过中心并包含两个点上的圆

I have been able to draw the two circles scaled in pixels on my screen using a transformation method that transformed distance in metres to corresponding pixel distances. The next step is to draw a plus inside the circle; the lines being the diameters. Hence they will pass through the center and contain two points on the circle.

1)我有圆的中心的纬度长和像素的信息。

1)I have the lat long and pixel details of the center of the circle.

2)我知道中心和圆的或者点之间的角度必须是90度。

2)I know that the angle between the center and the either points on the circle need to be 90 degrees.

3)我必须用canvas.drawLine()。

3)I must use canvas.drawLine().

但是,这将是获得该圆这些点使得线可以通过这些三个点被绘制的最佳方式。

But what would be the best way to get these points on the circle so that a line can be drawn through these three points.

(点上圆上方,圆心,点上底部的圆圈)。

大大AP preciate你的帮助。

Greatly appreciate your help.

编辑:
我尝试以下code经过一番搜索

I tried the following code after some searching

        //double degrees = 90.0;
        //double radians = Math.toRadians(degrees);
        //int x1 = (int) (500 * Math.cos(radians) + x);
        //int y1 = (int) (500 * Math.sin(radians) + y);      
        //canvas.drawLine(x, y, x1, y1, mSelectionBrush);


        canvas.drawLine(x, y-500, x, y+500, mSelectionBrush);
    canvas.drawLine(x-500, y, x+500, y, mSelectionBrush);

x,y是该中心的坐标。 500是外圆的半径。
我看到的输出是这样的。线下延伸。我要去的正确方法?

x,y are the coordinates of the center. 500 is the radius of the outer circle. The output I see is this. The line extends below. Am I going the right way?

推荐答案

我认为你是在正确的轨道上。请注意,只为Y的垂直线变化。
假设中心由下式给出:(A,B)
所以端点将是
(A,B-R)和(A,B + R)

I think you're on the right track. Notice that only Y changes for the vertical line. Assuming center is given by C(a,b) So the end-points would be (a,b-r) and (a,b+r)

有关水平线只有x的变化:
(A-R,B)和(a + R,B)将是终点。

For the horizontal line only x changes: (a-r,b) and (a+r,b) would be the end-points.

r是半径。

这篇关于如何画一个直径的Andr​​oid圆的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆