Skip to content

Commit 3e5d607

Browse files
committed
method to plot plane
1 parent 185f8df commit 3e5d607

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎spatialmath/geom3d.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ def contains(self, p, tol=10*_eps):
115115
"""
116116
return abs(np.dot(self.n, p) - self.d) < tol
117117

118+
def plot(self, bounds=None, ax=None, **kwargs):
119+
ax = base.axes_logic(ax, 3)
120+
if bounds is None:
121+
bounds = np.r_[ax.get_xlim(), ax.get_ylim(), ax.get_zlim()]
122+
123+
# X, Y = np.meshgrid(bounds[0: 2], bounds[2: 4])
124+
# Z = -(X * self.plane[0] + Y * self.plane[1] + self.plane[3]) / self.plane[2]
125+
126+
X, Y = np.meshgrid(np.linspace(bounds[0], bounds[1], 50),
127+
np.linspace(bounds[2], bounds[3], 50))
128+
Z = -(X * self.plane[0] + Y * self.plane[1] + self.plane[3]) / self.plane[2]
129+
Z[Z < bounds[4]] = np.nan
130+
Z[Z > bounds[5]] = np.nan
131+
ax.plot_surface(X, Y, Z, **kwargs)
132+
118133
def __str__(self):
119134
"""
120135

0 commit comments

Comments
 (0)