1414
1515# ======================================================================== #
1616
17- class Plane :
17+ class Plane3 :
1818 r"""
1919 Create a plane object from linear coefficients
2020
@@ -126,7 +126,8 @@ def __str__(self):
126126
127127# ======================================================================== #
128128
129- class Plucker (BasePoseList ):
129+
130+ class Line3 (BasePoseList ):
130131 """
131132 Plucker coordinate class
132133
@@ -274,7 +275,7 @@ def TwoPoints(P=None, Q=None):
274275 # compute direction and moment
275276 w = P - Q
276277 v = np .cross (w , P )
277- return Plucker (np .r_ [v , w ])
278+ return cls (np .r_ [v , w ])
278279
279280 @staticmethod
280281 def TwoPlanes (pi1 , pi2 ):
@@ -297,17 +298,19 @@ def TwoPlanes(pi1, pi2):
297298 :seealso: Plucker, Plucker.PQ, Plucker.PointDir
298299 """
299300
300- if not isinstance (pi1 , Plane ):
301- pi1 = Plane (base .getvector (pi1 , 4 ))
302- if not isinstance (pi2 , Plane ):
303- pi2 = Plane (base .getvector (pi2 , 4 ))
301+ # TODO inefficient to create 2 temporary planes
302+
303+ if not isinstance (pi1 , Plane3 ):
304+ pi1 = Plane3 (base .getvector (pi1 , 4 ))
305+ if not isinstance (pi2 , Plane3 ):
306+ pi2 = Plane3 (base .getvector (pi2 , 4 ))
304307
305308 w = np .cross (pi1 .n , pi2 .n )
306309 v = pi2 .d * pi1 .n - pi1 .d * pi2 .n
307- return Plucker (np .r_ [v , w ])
310+ return cls (np .r_ [v , w ])
308311
309- @staticmethod
310- def PointDir (point , dir ):
312+ @classmethod
313+ def PointDir (cls , point , dir ):
311314 """
312315 Create Plucker line from point and direction
313316
@@ -327,7 +330,7 @@ def PointDir(point, dir):
327330 p = base .getvector (point , 3 )
328331 w = base .getvector (dir , 3 )
329332 v = np .cross (w , p )
330- return Plucker (np .r_ [v , w ])
333+ return cls (np .r_ [v , w ])
331334
332335 def append (self , x ):
333336 """
@@ -775,7 +778,7 @@ def commonperp(self, l2): # pylint: disable=no-self-argument
775778 v = np .cross (l1 .v , l2 .w ) - np .cross (l2 .v , l1 .w ) + \
776779 (l1 * l2 ) * np .dot (l1 .w , l2 .w ) * base .unitvec (np .cross (l1 .w , l2 .w ))
777780
778- return Plucker (v , w )
781+ return self . __class__ (v , w )
779782
780783
781784 def __mul__ (self , right ): # pylint: disable=no-self-argument
@@ -826,7 +829,7 @@ def __rmul__(self, left): # pylint: disable=no-self-argument
826829 A = np .r_ [ np .c_ [left .R , base .skew (- left .t ) @ left .R ],
827830 np .c_ [np .zeros ((3 ,3 )), left .R ]
828831 ]
829- return Plucker ( A @ right .vec ) # premultiply by SE3
832+ return self . __class__ ( A @ right .vec ) # premultiply by SE3
830833 else :
831834 raise ValueError ('bad arguments' )
832835
@@ -871,8 +874,8 @@ def intersect_plane(self, plane): # pylint: disable=no-self-argument
871874 # Note that this is in homogeneous coordinates.
872875 # intersection of plane (n,p) with the line (v,p)
873876 # returns point and line parameter
874- if not isinstance (plane , Plane ):
875- plane = Plane (base .getvector (plane , 4 ))
877+ if not isinstance (plane , Plane3 ):
878+ plane = Plane3 (base .getvector (plane , 4 ))
876879
877880 den = np .dot (self .w , plane .n )
878881
@@ -937,7 +940,7 @@ def intersect_volume(self, bounds):
937940 I = np .eye (3 ,3 )
938941 p = [0 , 0 , 0 ]
939942 p [i ] = bounds [face ]
940- plane = Plane .PN (n = I [:,i ], p = p )
943+ plane = Plane3 .PN (n = I [:,i ], p = p )
941944
942945 # find where line pierces the plane
943946 try :
@@ -1121,13 +1124,24 @@ def _repr_pretty_(self, p, cycle):
11211124
11221125 # Static factory methods for constructors from exotic representations
11231126
1127+ class Plucker (Line3 ):
11241128
1129+ def __init__ (self , v = None , w = None ):
1130+ import warnings
1131+
1132+ warnings .warn ('use Line class instead' , DeprecationWarning )
1133+ super ().__init__ (v , w )
11251134
11261135if __name__ == '__main__' : # pragma: no cover
11271136
11281137 import pathlib
11291138 import os .path
1139+
1140+ a = Plane3 ([0.1 , - 1 , - 1 , 2 ])
1141+ base .plotvol3 (5 )
1142+ a .plot (color = 'r' , alpha = 0.3 )
1143+ plt .show (block = True )
11301144
1131- a = SE3 .Exp ([2 ,0 ,0 ,0 ,0 ,0 ])
1145+ # a = SE3.Exp([2,0,0,0,0,0])
11321146
1133- exec (open (pathlib .Path (__file__ ).parent .parent .absolute () / "tests" / "test_geom3d.py" ).read ()) # pylint: disable=exec-used
1147+ # exec(open(pathlib.Path(__file__).parent.parent.absolute() / "tests" / "test_geom3d.py").read()) # pylint: disable=exec-used
0 commit comments