8000 Change names of Plucker constructors to TwoPoints and TwoPlanes · suddrey-qut/spatialmath-python@df67ee8 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit df67ee8

Browse files
committed
Change names of Plucker constructors to TwoPoints and TwoPlanes
1 parent 60f5bf7 commit df67ee8

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

spatialmath/geom3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def isvalid(x, check=False):
252252
return x.shape == (6,)
253253

254254
@staticmethod
255-
def Points2(P=None, Q=None):
255+
def TwoPoints(P=None, Q=None):
256256
"""
257257
Create Plucker line object from two 3D points
258258
@@ -277,7 +277,7 @@ def Points2(P=None, Q=None):
277277
return Plucker(np.r_[v, w])
278278

279279
@staticmethod
280-
def Planes2(pi1, pi2):
280+
def TwoPlanes(pi1, pi2):
281281
r"""
282282
Create Plucker line from two planes
283283

tests/test_geom3d.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_constructor2(self):
4545
# 2, point constructor
4646
P = np.r_[2, 3, 7]
4747
Q = np.r_[2, 1, 0]
48-
L = Plucker.PQ(P, Q)
48+
L = Plucker.TwoPoints(P, Q)
4949
nt.assert_array_almost_equal(L.w, P-Q)
5050
nt.assert_array_almost_equal(L.v, np.cross(P-Q, Q))
5151

@@ -74,7 +74,7 @@ def test_constructor2(self):
7474

7575
def test_pp(self):
7676
# validate pp and ppd
77-
L = Plucker.PQ([-1, 1, 2], [1, 1, 2])
77+
L = Plucker.TwoPoints([-1, 1, 2], [1, 1, 2])
7878
nt.assert_array_almost_equal(L.pp, np.r_[0, 1, 2])
7979
self.assertEqual(L.ppd, math.sqrt(5))
8080

@@ -85,7 +85,7 @@ def test_pp(self):
8585
def test_contains(self):
8686
P = [2, 3, 7]
8787
Q = [2, 1, 0]
88-
L = Plucker.PQ(P, Q)
88+
L = Plucker.TwoPoints(P, Q)
8989

9090
# validate contains
9191
self.assertTrue( L.contains([2, 3, 7]) )
@@ -96,39 +96,39 @@ def test_contains(self):
9696
def test_closest(self):
9797
P = [2, 3, 7]
9898
Q = [2, 1, 0]
99-
L = Plucker.PQ(P, Q)
99+
L = Plucker.TwoPoints(P, Q)
100100

101-
out = L.closest(P)
101+
out = L.closest_to_point(P)
102102
nt.assert_array_almost_equal(out.p, P)
103103
self.assertAlmostEqual(out.d, 0)
104104

105105
# validate closest with given points and origin
106-
out = L.closest(Q)
106+
out = L.closest_to_point(Q)
107107
nt.assert_array_almost_equal(out.p, Q)
108108
self.assertAlmostEqual(out.d, 0)
109109

110-
L = Plucker.PQ([-1, 1, 2], [1, 1, 2])
111-
out = L.closest([0, 1, 2])
110+
L = Plucker.TwoPoints([-1, 1, 2], [1, 1, 2])
111+
out = L.closest_to_point([0, 1, 2])
112112
nt.assert_array_almost_equal(out.p, np.r_[0, 1, 2])
113113
self.assertAlmostEqual(out.d, 0)
114114

115-
out = L.closest([5, 1, 2])
115+
out = L.closest_to_point([5, 1, 2])
116116
nt.assert_array_almost_equal(out.p, np.r_[5, 1, 2])
117117
self.assertAlmostEqual(out.d, 0)
118118

119-
out = L.closest([0, 0, 0])
119+
out = L.closest_to_point([0, 0, 0])
120120
nt.assert_array_almost_equal(out.p, L.pp)
121121
self.assertEqual(out.d, L.ppd)
122122

123-
out = L.closest([5, 1, 0])
123+
out = L.closest_to_point([5, 1, 0])
124124
nt.assert_array_almost_equal(out.p, [5, 1, 2])
125125
self.assertAlmostEqual(out.d, 2)
126126

127127
def test_plot(self):
128128

129129
P = [2, 3, 7]
130130
Q = [2, 1, 0]
131-
L = Plucker.PQ(P, Q)
131+
L = Plucker.TwoPoints(P, Q)
132132

133133
fig = plt.figure()
134134
ax = fig.add_subplot(111, projection='3d', proj_type='ortho')
@@ -142,9 +142,9 @@ def test_eq(self):
142142
w = np.r_[1, 2, 3]
143143
P = np.r_[-2, 4, 3]
144144

145-
L1 = Plucker.PQ(P, P + w)
146-
L2 = Plucker.PQ(P + 2 * w, P + 5 * w)
147-
L3 = Plucker.PQ(P + np.r_[1, 0, 0], P + w)
145+
L1 = Plucker.TwoPoints(P, P + w)
146+
L2 = Plucker.TwoPoints(P + 2 * w, P + 5 * w)
147+
L3 = Plucker.TwoPoints(P + np.r_[1, 0, 0], P + w)
148148

149149
self.assertTrue(L1 == L2)
150150
self.assertFalse(L1 == L3)
@@ -155,7 +155,7 @@ def test_eq(self):
155155
def test_skew(self):
156156

157157
P = [2, 3, 7]; Q = [2, 1, 0]
158-
L = Plucker.PQ(P, Q)
158+
L = Plucker.TwoPoints(P, Q)
159159

160160
m = L.skew
161161

@@ -165,7 +165,7 @@ def test_skew(self):
165165
def test_mtimes(self):
166166
P = [1, 2, 0]
167167
Q = [1, 2, 10] # vertical line through (1,2)
168-
L = Plucker.PQ(P, Q)
168+
L = Plucker.TwoPoints(P, Q)
169169

170170
# check transformation by SE3
171171

@@ -242,7 +242,7 @@ def test_line(self):
242242
def test_contains(self):
243243
P = [2, 3, 7]
244244
Q = [2, 1, 0]
245-
L = Pluc F438 ker.PQ(P, Q)
245+
L = Plucker.TwoPoints(P, Q)
246246

247247
self.assertTrue( L.contains(L.point(0)) )
248248
self.assertTrue( L.contains(L.point(1)) )
@@ -251,7 +251,7 @@ def test_contains(self):
251251
def test_point(self):
252252
P = [2, 3, 7]
253253
Q = [2, 1, 0]
254-
L = Plucker.PQ(P, Q)
254+
L = Plucker.TwoPoints(P, Q)
255255

256256
nt.assert_array_almost_equal(L.point(0).flatten(), L.pp)
257257

@@ -261,7 +261,7 @@ def test_point(self):
261261
def test_char(self):
262262
P = [2, 3, 7]
263263
Q = [2, 1, 0]
264-
L = Plucker.PQ(P, Q)
264+
L = Plucker.TwoPoints(P, Q)
265265

266266
s = str(L)
267267
self.assertIsInstance(s, str)
@@ -271,10 +271,10 @@ def test_plane(self):
271271

272272
xyplane = [0, 0, 1, 0]
273273
xzplane = [0, 1, 0, 0]
274-
L = Plucker.Planes(xyplane, xzplane) # x axis
274+
L = Plucker.TwoPlanes(xyplane, xzplane) # x axis
275275
nt.assert_array_almost_equal(L.vec, np.r_[0, 0, 0, -1, 0, 0])
276276

277-
L = Plucker.PQ([-1, 2, 3], [1, 2, 3]); # line at y=2,z=3
277+
L = Plucker.TwoPoints([-1, 2, 3], [1, 2, 3]); # line at y=2,z=3
278278
x6 = [1, 0, 0, -6] # x = 6
279279

280280
# plane_intersect
@@ -291,9 +291,9 @@ def test_plane(self):
291291

292292
def test_methods(self):
293293
# intersection
294-
px = Plucker.PQ([0, 0, 0], [1, 0, 0]); # x-axis
295-
py = Plucker.PQ([0, 0, 0], [0, 1, 0]); # y-axis
296-
px1 = Plucker.PQ([0, 1, 0], [1, 1, 0]); # offset x-axis
294+
px = Plucker.TwoPoints([0, 0, 0], [1, 0, 0]); # x-axis
295+
py = Plucker.TwoPoints([0, 0, 0], [0, 1, 0]); # y-axis
296+
px1 = Plucker.TwoPoints([0, 1, 0], [1, 1, 0]); # offset x-axis
297297

298298
self.assertEqual(px.ppd, 0)
299299
self.assertEqual(px1.ppd, 1)

0 commit comments

Comments
 (0)
0