[Python] Summary of mathematical conversion processing (orthogonal coordinate, polar coordinate conversion, etc.) [math, numpy, etc.]

Find Cartesian coordinates (x, y) from polar coordinates (r, Θ)

def getXY(r, degree):
    #Convert degrees to radians
    rad = math.radians(degree)
    x = r * math.cos(rad)
    y = r * math.sin(rad)
    print(x, y)
    return x, y

Find polar coordinates (r, Θ) from Cartesian coordinates (x, y)

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

Find the polar coordinates (r, Θ) from the origin xy to a specific XY

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

Recommended Posts

[Python] Summary of mathematical conversion processing (orthogonal coordinate, polar coordinate conversion, etc.) [math, numpy, etc.]
[Language processing 100 knocks 2020] Summary of answer examples by Python
[Python] Conversion from WGS84 to plane orthogonal coordinate system
[Kaggle] Summary of pre-processing (statistics, missing value processing, etc.)
Summary of date processing in Python (datetime and dateutil)
Summary of Python arguments
Various processing of Python
Summary of python file operations
Summary of Python3 list operations
Post processing of python (NG)