Convert Vector to Polar Angle (Python)

vector
polar
rhinopython
python

#1

I am trying to write a Python script that converts a vector to a polar angle on my current Cplane. For example:

[1,0,0] = 0°
[0,1,0] = 90°
[-1,0,0] = 180°
[0,-1,0] = 270° (or -90° would work too)

what would be the easiest way to accomplish this with a known vector?


#2

It’s indeed just calling methods:

import math
import Rhino.Geometry as rg

for v in [[1,0,0], [0,1,0], [-1,0,0], [0,-1,0]]:
    rad = rg.Vector3d.VectorAngle(rg.Vector3d.XAxis, rg.Vector3d(*v), rg.Plane.WorldXY)
    deg = math.degrees(rad)
    print deg

#3

That works great! Thanks for the help! :smiley: