MAGIKS  1.1
Manipulator General Inverse Kinematic Solver
 All Classes Namespaces Files Functions Variables Pages
complex.py
Go to the documentation of this file.
1 
2 ## @file complex.py
3 # @brief this module provides tools by which you can work with complex numbers
4 # @author Nima Ramezani Taghiabadi
5 #
6 # PhD Researcher
7 # Faculty of Engineering and Information Technology
8 # University of Technology Sydney (UTS)
9 # Broadway, Ultimo, NSW 2007, Australia
10 # Phone No. : 04 5027 4611
11 # Email(1) : nima.ramezani@gmail.com
12 # Email(2) : Nima.RamezaniTaghiabadi@uts.edu.au
13 # @version 1.0
14 #
15 # Start date: Februaty 2010
16 # Last Revision: 03 January 2015
17 
18 import math
19 
21 
22  def __init__(self):
23 
24  self.ro = 0
25  self.teta = 0
26  self.re = 0
27  self.im = 0
28 
29  def polar_to_cartesian(self):
30 
31  self.re = self.ro*math.cos(self.teta)
32  self.im = self.ro*math.sin(self.teta)
33 
34  def cartesian_to_polar(self):
35 
36  self.ro = math.sqrt(self.re*self-re+self.im*self.im)
37  self.teta = math.atan2(self.im,self.re)
38 
39 
40 
41 
42 
43 def complex_multiply(c1,c2):
44 
45  '''
46  This function multiplies c1 and c2 and returns the product
47  '''
48 
49  c3.re = c1.re*c2.re-c1.im*c2.im
50  c3.im = c1.re*c2.im+c1.im*c2.re
51 
52  c3.ro = c1.ro * c2.ro
53  c3.teta = c1.teta + c2.teta
54 
55  while c3.teta > 2*math.pi:
56  c3.teta = c3.teta-2*math.pi
57 
58  while c3.teta < -2*math.pi:
59  c3.teta = c3.teta+2*math.pi
60