Android初学者,有人可以指导我吗?
我确实有距离,角度和原点。
newx = (distance * cosθ) + origin.x;
newy = (distance * sinθ) + origin.y;
而不是这个,我可以在Android中依赖默认的API
答案 0 :(得分:3)
如果内存服务,一些简单的三角函数将帮助你:
public static PointF getPoint(PointF origin, float distance, float angle)
{
float x = Math.cos(angle)*distance;
float y = Math.sin(angle)*distance;
return origin.offset(x,y);
}
答案 1 :(得分:3)
你的问题不明确:你不了解Android或极坐标的表达式吗?
后者很简单:
/**
* Factory for PointF
* @param origin of the coordinate system (not needed)
* @param distance this really means "radius"
* @param angle from the x-axis in radians; positive increases in the counterclockwise direction
*/
public static PointF getPoint(PointF origin, float distance, float angle)
{
PointF newPoint = new PointF();
newPoint.x = origin.x + distance*Math.cos(angle);
newPoint.y = origin.y + distance*Math.sin(angle);
return newPoint;
}