LoginSignup
7
4

More than 3 years have passed since last update.

【Python】数学的な変換処理まとめ(直行座標や極座標変換など)【math, numpy等】

Posted at

極座標(r, Θ)から直交座標(x, y)を求める

def getXY(r, degree):
    # 度をラジアンに変換
    rad = math.radians(degree)
    x = r * math.cos(rad)
    y = r * math.sin(rad)
    print(x, y)
    return x, y

直交座標(x, y)から極座標(r, Θ)を求める

def getRD(x, y):
    r = math.sqrt(x**2+y**2)
    rad = math.atan2(y, x)
    degree = math.degrees(rad)
    print(r, degree)
    return r, degree

原点xyから特定のXYへの極座標(r, Θ)を求める

def getxy_RD(x, y, X, Y):
    _x, _y = (X-x), (Y-y)
    r = math.sqrt(_x**2+_y**2)
    rad = math.atan2(_y, _x)
    degree = math.degrees(rad)
    print(r, degree)
    return r, degree
7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4