I am currently building a small compass app and I have drawn the north and south line using simple circle equation: x= a+r Cos(t) and y= b+ r Sin(t) where t=heading or direction in degree(angle). More info in Wiki
So far I have manged to get the north and south line. Here is my work
//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);
My problem: I don't know how do we get the east and west line?
CxCompass, CyCompass: coordinates of circle center
Fixed the issue by adding 90 degrees. I am happy to share it
//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);