-2
Android初學者,有人能指導我嗎?球體的XYZ座標
我確實有距離,角度和原點。
newx = (distance * cosθ) + origin.x;
newy = (distance * sinθ) + origin.y;
相反的,這是沒有任何默認的API,我可以依賴於Android的
Android初學者,有人能指導我嗎?球體的XYZ座標
我確實有距離,角度和原點。
newx = (distance * cosθ) + origin.x;
newy = (distance * sinθ) + origin.y;
相反的,這是沒有任何默認的API,我可以依賴於Android的
你的問題不明確:你不瞭解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;
}
如果沒有記錯一些簡單的三角函數會幫助你在這裏:
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);
}
你意味着你確實有一個算法//的數學制定出來,但與Java/Android的掙扎?如果你可以添加算法以及你不確定的點,我肯定幫助會更快:)。 – Nanne 2012-02-24 10:27:08
SO不是「gimi a code」服務 – Selvin 2012-02-24 10:28:27