Skip to content

Commit a9ee009

Browse files
committed
add some comments
1 parent 95a9eff commit a9ee009

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

robot/Quaternion.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: UTF-8 -*-
3+
14
"""
25
Quaternion class.
36
@@ -118,7 +121,7 @@ def __init__(self, *args):
118121

119122
else:
120123
print "error"
121-
return None
124+
return
122125

123126
def __repr__(self):
124127
return "%f <%f, %f, %f>" % (self.s, self.v[0,0], self.v[0,1], self.v[0,2])
@@ -278,7 +281,7 @@ def __imul__(self, x):
278281
'''
279282

280283
if isinstance(x, quaternion):
281-
s1 = self.s;
284+
s1 = self.s
282285
v1 = self.v
283286
s2 = x.s
284287
v2 = x.v
@@ -299,8 +302,8 @@ def __div__(self, q):
299302
- q1 / q2 quaternion division implemented as q1 * q2.inv()
300303
- q1 / c element-wise division
301304
'''
305+
qr = quaternion()
302306
if isinstance(q, quaternion):
303-
qr = quaternion()
304307
qr = self * q.inv()
305308
elif isscalar(q):
306309
qr.s = self.s / q
@@ -388,11 +391,10 @@ def unit(self):
388391

389392
def tr(self):
390393
"""Return an equivalent rotation matrix.
391-
394+
注意, 四元素仅表示转动
392395
@rtype: 4x4 homogeneous transform
393-
@return: equivalent rotation matrix
396+
@return: homogeneous transform
394397
"""
395-
396398
return T.r2t( self.r() )
397399

398400
def r(self):
@@ -449,7 +451,7 @@ def interp(Q1, Q2, r):
449451

450452
if isscalar(r):
451453
if r<0 or r>1:
452-
raise 'R out of range'
454+
raise IndexError,'R out of range'
453455
if theta == 0:
454456
q = quaternion(Q1)
455457
else:

0 commit comments

Comments
 (0)