Skip to content

Commit 7c21aff

Browse files
committed
change names of Line3 methods to Join, IntersectingPlanes
1 parent a4798bc commit 7c21aff

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

spatialmath/geom3d.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def isvalid(x, check=False):
261261
return x.shape == (6,)
262262

263263
@classmethod
264-
def TwoPoints(cls, P=None, Q=None):
264+
def Join(cls, P=None, Q=None):
265265
"""
266266
Create 3D line from two 3D points
267267
@@ -272,11 +272,11 @@ def TwoPoints(cls, P=None, Q=None):
272272
:return: 3D line
273273
:rtype: ``Line3`` instance
274274
275-
``Line3(P, Q)`` create a ``Line3`` object that represents
275+
``Line3.Join(P, Q)`` create a ``Line3`` object that represents
276276
the line joining the 3D points ``P`` (3,) and ``Q`` (3,). The direction
277277
is from ``Q`` to ``P``.
278278
279-
:seealso: :meth:`Line3` :meth:`PointDir`
279+
:seealso: :meth:`IntersectingPlanes` :meth:`PointDir`
280280
"""
281281
P = base.getvector(P, 3)
282282
Q = base.getvector(Q, 3)
@@ -286,7 +286,7 @@ def TwoPoints(cls, P=None, Q=None):
286286
return cls(np.r_[v, w])
287287

288288
@classmethod
289-
def TwoPlanes(cls, pi1, pi2):
289+
def IntersectingPlanes(cls, pi1, pi2):
290290
r"""
291291
Create 3D line from intersection of two planes
292292
@@ -297,13 +297,13 @@ def TwoPlanes(cls, pi1, pi2):
297297
:return: 3D line
298298
:rtype: ``Line3`` instance
299299
300-
``L = Plucker.planes(PI1, PI2)`` is a Plucker object that represents
301-
the line formed by the intersection of two planes ``PI1`` and ``PI2``.
300+
``L = Plucker.IntersectingPlanes(π1, π2)`` is a Plucker object that represents
301+
the line formed by the intersection of two planes ``π1`` and ``π3``.
302302
303303
Planes are represented by the 4-vector :math:`[a, b, c, d]` which describes
304304
the plane :math:`\pi: ax + by + cz + d=0`.
305305
306-
:seealso: :meth:`TwoPoints` :meth:`PointDir`
306+
:seealso: :meth:`Join` :meth:`PointDir`
307307
"""
308308

309309
# TODO inefficient to create 2 temporary planes
@@ -332,7 +332,7 @@ def PointDir(cls, point, dir):
332332
``Line3.pointdir(P, W)`` is a Plucker object that represents the
333333
line containing the point ``P`` and parallel to the direction vector ``W``.
334334
335-
:seealso: :meth:`TwoPoints` :meth:`TwoPlanes`
335+
:seealso: :meth:`Join` :meth:`IntersectingPlanes`
336336
"""
337337

338338
p = base.getvector(point, 3)

tests/test_geom3d.py

Lines changed: 19 additions & 19 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 = Line3.TwoPoints(P, Q)
48+
L = Line3.Join(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 = Line3.TwoPoints([-1, 1, 2], [1, 1, 2])
77+
L = Line3.Join([-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 = Line3.TwoPoints(P, Q)
88+
L = Line3.Join(P, Q)
8989

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

101101
p, d = L.closest_to_point(P)
102102
nt.assert_array_almost_equal(p, P)
@@ -107,7 +107,7 @@ def test_closest(self):
107107
nt.assert_array_almost_equal(p, Q)
108108
self.assertAlmostEqual(d, 0)
109109

110-
L = Line3.TwoPoints([-1, 1, 2], [1, 1, 2])
110+
L = Line3.Join([-1, 1, 2], [1, 1, 2])
111111
p, d = L.closest_to_point([0, 1, 2])
112112
nt.assert_array_almost_equal(p, np.r_[0, 1, 2])
113113
self.assertAlmostEqual(d, 0)
@@ -128,7 +128,7 @@ def test_plot(self):
128128

129129
P = [2, 3, 7]
130130
Q = [2, 1, 0]
131-
L = Line3.TwoPoints(P, Q)
131+
L = Line3.Join(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 = Line3.TwoPoints(P, P + w)
146-
L2 = Line3.TwoPoints(P + 2 * w, P + 5 * w)
147-
L3 = Line3.TwoPoints(P + np.r_[1, 0, 0], P + w)
145+
L1 = Line3.Join(P, P + w)
146+
L2 = Line3.Join(P + 2 * w, P + 5 * w)
147+
L3 = Line3.Join(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 = Line3.TwoPoints(P, Q)
158+
L = Line3.Join(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 = Line3.TwoPoints(P, Q)
168+
L = Line3.Join(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 = Line3.TwoPoints(P, Q)
245+
L = Line3.Join(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 = Line3.TwoPoints(P, Q)
254+
L = Line3.Join(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 = Line3.TwoPoints(P, Q)
264+
L = Line3.Join(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 = Line3.TwoPlanes(xyplane, xzplane) # x axis
274+
L = Line3.IntersectingPlanes(xyplane, xzplane) # x axis
275275
nt.assert_array_almost_equal(L.vec, np.r_[0, 0, 0, -1, 0, 0])
276276

277-
L = Line3.TwoPoints([-1, 2, 3], [1, 2, 3]); # line at y=2,z=3
277+
L = Line3.Join([-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 = Line3.TwoPoints([0, 0, 0], [1, 0, 0]); # x-axis
295-
py = Line3.TwoPoints([0, 0, 0], [0, 1, 0]); # y-axis
296-
px1 = Line3.TwoPoints([0, 1, 0], [1, 1, 0]); # offset x-axis
294+
px = Line3.Join([0, 0, 0], [1, 0, 0]); # x-axis
295+
py = Line3.Join([0, 0, 0], [0, 1, 0]); # y-axis
296+
px1 = Line3.Join([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)