@@ -346,6 +346,14 @@ def __rmul__(self, mult):
346346 return self .__mul__ (mult )
347347
348348 def __div__ (self , div ):
349+ """A python2 compatibility wrapper."""
350+ return self .__truediv__ (div )
351+
352+ def __rdiv__ (self , div ):
353+ """A python2 compatibility wrapper."""
354+ return self .__rtruediv__ (div )
355+
356+ def __truediv__ (self , div ):
349357 """Divide the point by a scalar.
350358
351359 Parameters
@@ -367,6 +375,28 @@ def __div__(self, div):
367375 raise ValueError ('Type %s not supported. Only scalar division is supported' % (type (div )))
368376 return self .__mul__ (1.0 / div )
369377
378+ def __rtruediv__ (self , div ):
379+ """Divide the scalar by a point.
380+
381+ Parameters
382+ ----------
383+ div : float
384+ The number by which the Point is divided.
385+
386+ Returns
387+ -------
388+ :obj:`Point3D`
389+ A 3D point created by the division.
390+
391+ Raises
392+ ------
393+ ValueError
394+ If div is not a scalar value.
395+ """
396+ if isinstance (div , numbers .Number ):
397+ return Point (div / self ._data , self ._frame )
398+ raise ValueError ('Type %s not supported. Only scalar division is supported' % (type (div )))
399+
370400 @staticmethod
371401 def open (filename , frame = 'unspecified' ):
372402 """Create a Point from data saved in a file.
@@ -792,6 +822,14 @@ def __rmul__(self, mult):
792822 return self .__mul__ (mult )
793823
794824 def __div__ (self , div ):
825+ """A python2 compatibility wrapper."""
826+ return self .__truediv__ (div )
827+
828+ def __rdiv__ (self , div ):
829+ """A python2 compatibility wrapper."""
830+ return self .__rtruediv__ (div )
831+
832+ def __truediv__ (self , div ):
795833 """Divide each point in the cloud by a scalar.
796834
797835 Parameters
@@ -813,6 +851,28 @@ def __div__(self, div):
813851 raise ValueError ('Type %s not supported. Only scalar division is supported' % (type (div )))
814852 return self .__mul__ (1.0 / div )
815853
854+ def __rtruediv__ (self , div ):
855+ """Divide a scalar by each point in the cloud.
856+
857+ Parameters
858+ ----------
859+ div : float
860+ The number by which the PointCloud is divided.
861+
862+ Returns
863+ -------
864+ :obj:`PointCloud`
865+ A PointCloud created by the division.
866+
867+ Raises
868+ ------
869+ ValueError
870+ If div is not a scalar value.
871+ """
872+ if isinstance (div , numbers .Number ):
873+ return PointCloud (div / self ._data , self ._frame )
874+ raise ValueError ('Type %s not supported. Only scalar division is supported' % (type (div )))
875+
816876 @staticmethod
817877 def open (filename , frame = 'unspecified' ):
818878 """Create a PointCloud from data saved in a file.
@@ -1210,4 +1270,3 @@ def remove_zero_points(self):
12101270 (np .isfinite (self .normal_cloud .data [0 ,:])))[0 ]
12111271 self .point_cloud ._data = self .point_cloud .data [:, points_of_interest ]
12121272 self .normal_cloud ._data = self .normal_cloud .data [:, points_of_interest ]
1213-
0 commit comments