-1

我目前正在构建一个小型指南针应用程序,并使用简单的圆方程绘制了南北线:x= a+r Cos(t) and y= b+ r Sin(t) where t=heading or direction in degree(angle )。更多信息在 Wiki

到目前为止,我已经设法获得了南北线。这是我的工作

    //canvas.drawLine(startX, startY, stopX, stopY, paint)

    //Drawing North
        canvas.drawLine(cxCompass, cyCompass, 
                (float)(cxCompass + radiusCompass * Math.sin((double)(-direction) * 3.14/180)), 
                (float)(cyCompass - radiusCompass * Math.cos((double)(-direction) * 3.14/180)), 
                paint);

    //Drawing South
        canvas.drawLine(cxCompass, cyCompass, 
                (float)(cxCompass - radiusCompass * Math.sin((double)(-direction) * 3.14/180)), 
                (float)(cyCompass + radiusCompass * Math.cos((double)(-direction) * 3.14/180)), 
                paint);

我的问题:我不知道我们如何获得东西线?

CxCompass, CyCompass:圆心坐标

4

1 回答 1

0

通过添加 90 度修复了该问题。我很乐意分享

            //Drawing west
        canvas.drawLine(cxCompass, cyCompass, 
                (float)(cxCompass + radiusCompass * Math.sin((double)(-direction-90) * 3.14/180)), 
                (float)(cyCompass - radiusCompass * Math.cos((double)(-direction-90) * 3.14/180)), 
                paint);

        //Drawing east
        canvas.drawLine(cxCompass, cyCompass, 
                (float)(cxCompass - radiusCompass * Math.sin((double)(-direction-90) * 3.14/180)), 
                (float)(cyCompass + radiusCompass * Math.cos((double)(-direction-90) * 3.14/180)), 
                paint);
于 2013-11-11T18:52:34.210 回答