MCPcopy Create free account
hub / github.com/NanoComp/meep / rotate

Method rotate

python/geom.py:234–249  ·  view source on GitHub ↗

Returns the vector rotated by an angle *`theta`* (in radians) in the right-hand direction around the *`axis`* vector (whose length is ignored). You may find the python functions `math.degrees` and `math.radians` useful to convert angles between degrees and radians.

(self, axis, theta)

Source from the content-addressed store, hash-verified

232 )
233
234 def rotate(self, axis, theta):
235 """
236 Returns the vector rotated by an angle *`theta`* (in radians) in the right-hand
237 direction around the *`axis`* vector (whose length is ignored). You may find the
238 python functions `math.degrees` and `math.radians` useful to convert angles
239 between degrees and radians.
240
241 ```python
242 v2 = v1.rotate(axis, theta)
243 ```
244 """
245 u = axis.unit()
246 vpar = u.scale(u.dot(self))
247 vcross = u.cross(self)
248 vperp = self - vpar
249 return vpar + (vperp.scale(math.cos(theta)) + vcross.scale(math.sin(theta)))
250
251 # rotate vectors in lattice/reciprocal coords (note that the axis
252 # is also given in the corresponding basis):

Callers 2

test_rotateMethod · 0.95
gaussian_beamMethod · 0.95

Calls 4

unitMethod · 0.80
dotMethod · 0.80
crossMethod · 0.80
scaleMethod · 0.45

Tested by 2

test_rotateMethod · 0.76
gaussian_beamMethod · 0.76