Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce1b324

Browse files
committedNov 23, 2019
rotatePosition->angleAxisRotation
1 parent 8321a79 commit ce1b324

File tree

12 files changed

+32
-32
lines changed

12 files changed

+32
-32
lines changed
 

‎CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Click here for [Unreleased Changes]
1919
- getBsweep and multiprocessing options have been completely removed, this functionality
2020
should be overtaken by the new getBv function
2121
- Docstrings are being adjusted to work with intellisense
22-
- public rotatePosition() is now called angleAxisRotation_priv()
22+
- public angleAxisRotation() is now called angleAxisRotation_priv()
2323

2424
### Added
2525
- Vector functionality in form of the top-level function getBv applying vectorized code

‎docs/_pages/0_documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,14 @@ The math package provides some functions for easier use of the angle-axis (Quate
388388
print(ax) #Output = [-0.24834468 0.96858637 0.01285925]
389389
```
390390

391-
- `rotatePosition(pos, angle, axis, anchor=[0,0,0])`: This function uses angle-axis rotation to rotate the position vector `pos` by the `angle` argument about an axis defined by the `axis` vector which passes through the `anchor` position.
391+
- `angleAxisRotation(pos, angle, axis, anchor=[0,0,0])`: This function uses angle-axis rotation to rotate the position vector `pos` by the `angle` argument about an axis defined by the `axis` vector which passes through the `anchor` position.
392392
```python
393393
import magpylib as magpy
394394
pos0 = [1,1,0]
395395
angle = -90
396396
axis = [0,0,1]
397397
anchor = [1,0,0]
398-
positionNew = magpy.math.rotatePosition(pos0,angle,axis,anchor)
398+
positionNew = magpy.math.angleAxisRotation(pos0,angle,axis,anchor)
399399
print(positionNew) #Output = [2. 0. 0.]
400400
```
401401

‎docs/pyplots/examples/03b_Bsweep2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
for th in np.linspace(1,thMAX,30):
2525

2626
#rotation of the magnet position outwards
27-
posis = [math.rotatePosition(p0,th,ax,anchor=[0,0,gap+H+d]) for ax in axes]
27+
posis = [math.angleAxisRotation(p0,th,ax,anchor=[0,0,gap+H+d]) for ax in axes]
2828

2929
#generate INPUT
3030
INPUT += [[[0,0,0],pos,[th,ax]] for pos,ax in zip(posis,axes)]

‎magpylib/_lib/classes/sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from magpylib._lib.classes.base import RCS
2626
from magpylib._lib.utility import addUniqueSource, addListToCollection, isSource
27-
from magpylib._lib.mathLib import rotatePosition
27+
from magpylib._lib.mathLib import angleAxisRotation
2828

2929
class Sensor(RCS):
3030
"""
@@ -107,7 +107,7 @@ def getB(self, *sources, dupWarning=True):
107107

108108
# Read the field from all nominated sources
109109
Btotal = sum([s.getB(self.position) for s in sources])
110-
return rotatePosition(Btotal,
110+
return angleAxisRotation(Btotal,
111111
-self.angle, # Rotate in the opposite direction
112112
self.axis,
113113
[0, 0, 0])

‎magpylib/_lib/displaySystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from magpylib._lib.utility import drawCurrentArrows, drawMagAxis, drawDipole, isDisplayMarker
3535
from magpylib._lib.utility import drawSensor, isSensor
3636
from magpylib._lib.mathLib import angleAxisRotation_priv
37-
from magpylib._lib.mathLib import rotatePosition
37+
from magpylib._lib.mathLib import angleAxisRotation
3838
from magpylib import Collection
3939

4040

@@ -358,7 +358,7 @@ def displaySystem(sources, markers=listOfPos, subplotAx=None,
358358
currentsList.append(sCopyWithVertices)
359359

360360
elif type(s) is Dipole:
361-
P = rotatePosition(s.position, s.angle, s.axis)
361+
P = angleAxisRotation(s.position, s.angle, s.axis)
362362
maxSize = amax(abs(P))
363363
if maxSize > SYSSIZE:
364364
SYSSIZE = maxSize

‎magpylib/_lib/getBvector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# -------------------------------------------------------------------------------
2424
from magpylib._lib.fields.PM_Box_vector import Bfield_BoxV
2525
from magpylib._lib.fields.PM_Sphere_vector import Bfield_SphereV
26-
from magpylib._lib.mathLib_vector import QconjV, QrotationV, QmultV, getRotQuatV, rotatePositionV
26+
from magpylib._lib.mathLib_vector import QconjV, QrotationV, QmultV, getRotQuatV, angleAxisRotationV_priv
2727
import numpy as np
2828

2929
def getBv(type,MAG,DIM,POSo,POSm,ANG=[],AX=[],ANCH=[]):
@@ -81,7 +81,7 @@ def getBv(type,MAG,DIM,POSo,POSm,ANG=[],AX=[],ANCH=[]):
8181
#apply rotation operations
8282
for ANGLE,AXIS,ANCHOR in zip(ANG,AX,ANCH):
8383
Q = QmultV(getRotQuatV(ANGLE,AXIS),Q)
84-
Pm = rotatePositionV(ANGLE,AXIS,Pm-ANCHOR)+ANCHOR
84+
Pm = angleAxisRotationV_priv(ANGLE,AXIS,Pm-ANCHOR)+ANCHOR
8585

8686
#calculate the B-field
8787
POSrel = POSo-Pm #relative position

‎magpylib/_lib/mathLib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def anglesFromAxis(axis):
313313
return array([PHI, TH])
314314

315315

316-
def rotatePosition(position, angle, axis, anchor=[0, 0, 0]):
316+
def angleAxisRotation(position, angle, axis, anchor=[0, 0, 0]):
317317
"""
318318
This function uses angle-axis rotation to rotate the `position` vector by
319319
the `angle` argument about an axis defined by the `axis` vector which passes
@@ -348,7 +348,7 @@ def rotatePosition(position, angle, axis, anchor=[0, 0, 0]):
348348
>>> angle = -90
349349
>>> axis = [0,0,1]
350350
>>> centerOfRotation = [1,0,0]
351-
>>> positionNew = magPy.math.rotatePosition(position0,angle,axis,anchor=centerOfRotation)
351+
>>> positionNew = magPy.math.angleAxisRotation(position0,angle,axis,anchor=centerOfRotation)
352352
>>> print(positionNew)
353353
[2. 0. 0.]
354354
"""

‎magpylib/_lib/mathLib_vector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def getRotQuatV(angle, axis):
6262
return np.swapaxes(Q,0,1)
6363

6464
'''
65-
def rotatePositionV(angle, axis, v):
65+
def angleAxisRotationV_priv(angle, axis, v):
6666
"""
6767
rotates the vector v about axis by angle
6868
the anchor is the origin
@@ -121,7 +121,7 @@ def anglesFromAxisV():
121121
print('WIP')
122122
return 0
123123

124-
def rotatePositionV(ANGLE, AXIS, V):
124+
def angleAxisRotationV_priv(ANGLE, AXIS, V):
125125
"""
126126
rotates the vector v about axis by angle
127127
the anchor is the origin

‎magpylib/_lib/utility.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def drawMagnetizationVector(position, magnetization, angle, axis, color, SYSSIZE
107107
pyplot canvas to draw on
108108
109109
"""
110-
from magpylib._lib.mathLib import rotatePosition
111-
M = rotatePosition(magnetization, angle, axis)
110+
from magpylib._lib.mathLib import angleAxisRotation
111+
M = angleAxisRotation(magnetization, angle, axis)
112112
P = position
113113
# Get a lil different but unique tone
114114
c = [color[0]/2, color[1]/2, color[2]/2, color[3]]
@@ -131,8 +131,8 @@ def drawSensor(sensor, SYSSIZE, ax):
131131
pyplot canvas to draw on
132132
133133
"""
134-
from magpylib._lib.mathLib import rotatePosition
135-
M = rotatePosition([1,0,0],sensor.angle,sensor.axis)
134+
from magpylib._lib.mathLib import angleAxisRotation
135+
M = angleAxisRotation([1,0,0],sensor.angle,sensor.axis)
136136
P = sensor.position
137137
ax.quiver(P[0], P[1], P[2], # X position
138138
M[0], M[1], M[2], # Components of the Vector
@@ -141,15 +141,15 @@ def drawSensor(sensor, SYSSIZE, ax):
141141
color='r')
142142
ax.text(M[0]+P[0], M[1]+P[1], M[2]+P[2], "x", None)
143143

144-
M = rotatePosition([0,1,0],sensor.angle,sensor.axis)
144+
M = angleAxisRotation([0,1,0],sensor.angle,sensor.axis)
145145
ax.quiver(P[0], P[1], P[2], # Y position
146146
M[0], M[1], M[2], # Components of the Vector
147147
normalize=True,
148148
length=SYSSIZE/4,
149149
color='g')
150150
ax.text(M[0]+P[0], M[1]+P[1], M[2]+P[2], "y", None)
151151

152-
M = rotatePosition([0,0,1],sensor.angle,sensor.axis)
152+
M = angleAxisRotation([0,0,1],sensor.angle,sensor.axis)
153153
ax.quiver(P[0], P[1], P[2], # Z position
154154
M[0], M[1], M[2], # Components of the Vector
155155
normalize=True,
@@ -245,9 +245,9 @@ def drawDipole(position, moment, angle, axis, SYSSIZE, ax):
245245
canvas to draw on
246246
247247
"""
248-
from magpylib._lib.mathLib import rotatePosition
249-
P = rotatePosition(position, angle, axis)
250-
M = rotatePosition(moment, angle, axis)
248+
from magpylib._lib.mathLib import angleAxisRotation
249+
P = angleAxisRotation(position, angle, axis)
250+
M = angleAxisRotation(moment, angle, axis)
251251

252252
ax.quiver(P[0], P[1], P[2], # X,Y,Z position
253253
M[0], M[1], M[2], # Components of the Vector

‎magpylib/math/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
relations and genmeralized rotations.
2727
"""
2828
#__all__ = ["randomAxis", "axisFromAngles", "anglesFromAxis",
29-
# "rotatePosition"] # This is for Sphinx
29+
# "angleAxisRotation"] # This is for Sphinx
3030

3131
from magpylib._lib.mathLib import randomAxis
3232
from magpylib._lib.mathLib import axisFromAngles
3333
from magpylib._lib.mathLib import anglesFromAxis
34-
from magpylib._lib.mathLib import rotatePosition
34+
from magpylib._lib.mathLib import angleAxisRotation
3535

3636
from magpylib._lib.mathLib_vector import randomAxisV
3737
from magpylib._lib.mathLib_vector import axisFromAnglesV
3838
from magpylib._lib.mathLib_vector import anglesFromAxisV
39-
from magpylib._lib.mathLib_vector import rotatePositionV
39+
from magpylib._lib.mathLib_vector import angleAxisRotationV_priv

‎tests/test_Math.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from magpylib._lib.mathLib import Qmult, Qnorm2, Qunit, Qconj, getRotQuat, angleAxisRotation_priv
33
from magpylib._lib.mathLib import elliptic, ellipticK, ellipticE, ellipticPi
44
from numpy import pi,array
5-
from magpylib._lib.mathLib import randomAxis, axisFromAngles, anglesFromAxis, rotatePosition
5+
from magpylib._lib.mathLib import randomAxis, axisFromAngles, anglesFromAxis, angleAxisRotation
66
import numpy
77

88
# -------------------------------------------------------------------------------
@@ -13,11 +13,11 @@ def test_randomAxis():
1313
assert all(abs(axis)<=1 for axis in result), "bad randomAxis"
1414

1515
# -------------------------------------------------------------------------------
16-
def test_rotatePosition():
16+
def test_angleAxisRotation():
1717
sol = [-0.26138058, 0.59373138, 3.28125372]
18-
result = rotatePosition([1,2,3],234.5,(0,0.2,1),anchor=[0,1,0])
18+
result = angleAxisRotation([1,2,3],234.5,(0,0.2,1),anchor=[0,1,0])
1919
for r,s in zip(result,sol):
20-
assert round(r,4) == round(s,4), "bad rotatePosition"
20+
assert round(r,4) == round(s,4), "bad angleAxisRotation"
2121

2222
# -------------------------------------------------------------------------------
2323
def test_anglesFromAxis():

‎tests/test_magpyVector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from magpylib.source.magnet import Box
55
from magpylib import getBv
66
from magpylib.math import axisFromAngles
7-
from magpylib.math import rotatePositionV
7+
from magpylib.math import angleAxisRotationV_priv
88

99
def test_magpyVector():
1010

@@ -54,7 +54,7 @@ def getB(phi,th,psi):
5454

5555
ANG2 = np.array([a for a in TH for _ in range(Nphi*Npsi)])
5656
angles = np.array([a for a in PSI for _ in range(Nphi)]*Nth)
57-
AX2 = rotatePositionV(angles,np.array([[0,0,1]]*NN),np.array([[1,0,0]]*NN))
57+
AX2 = angleAxisRotationV_priv(angles,np.array([[0,0,1]]*NN),np.array([[1,0,0]]*NN))
5858
ANCH2 = np.array([anch]*NN)
5959

6060
Bv = getBv('box',MAG,DIM,POSo,POSm,[ANG1,ANG2],[AX1,AX2],[ANCH1,ANCH2])

0 commit comments

Comments
 (0)