LoginSignup
0
0

More than 5 years have passed since last update.

Rotation and to radian function example for complex number with python

Last updated at Posted at 2018-08-05
import math
import cmath

def to_rad(deg):
    return deg*math.pi/180

p1=[3,8]
p2=[13,8]
p2a=[p2[0]-p1[0],p2[1]-p1[1]]
print(p1,p2,p2a)
z2=complex(p2a[0],p2a[1])
zr1=complex(1/2,3**(1/2)/2)
zr2=complex(1/2,-3**(1/2)/2)

z31=z2*zr1
z32=z2*zr2

print(z31.real+p1[0],z31.imag+p1[1])
print(z32.real+p1[0],z32.imag+p1[1])
print(z2.real)
print(z2.imag)
[3, 8] [13, 8] [10, 0]
8.0 16.660254037844386
8.0 -0.6602540378443855
10.0
0.0

Refs.

http://www.geisya.or.jp/~mwm48961/koukou/rotation1.htm
https://note.nkmk.me/python-complex/
https://qiita.com/shuhei/items/f5cf6c83fcfb5dd24c2d
https://www.ajaxtower.jp/js/math_class/index10.html
https://juken-mikata.net/how-to/mathematics/radian.html

0
0
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
0
0