8000 parse out all box coords and do sanity checking · kh11kim/spatialmath-python@0f008b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f008b9

Browse files
committed
parse out all box coords and do sanity checking
remove default circle centre
1 parent d96a812 commit 0f008b9

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

spatialmath/base/graphics.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def plot_box(
355355
h = wh
356356
if centre is not None:
357357
cx, cy = centre
358+
358359
if l is None:
359360
try:
360361
l = r - w
@@ -365,14 +366,37 @@ def plot_box(
365366
l = cx - w / 2
366367
except:
367368
pass
368-
if b is None:
369+
370+
if r is None:
371+
try:
372+
r = l + w
373+
except:
374+
pass
375+
if r is None:
376+
try:
377+
r = cx + w / 2
378+
except:
379+
pass
380+
381+
if t is None:
369382
try:
370383
t = b + h
371384
except:
372385
pass
386+
if t is None:
387+
try:
388+
t = cy + h / 2
389+
except:
390+
pass
391+
373392
if b is None:
374393
try:
375-
t = cy - h / 2
394+
b = t - h
395+
except:
396+
pass
397+
if b is None:
398+
try:
399+
b = cy - h / 2
376400
except:
377401
pass
378402

@@ -471,7 +495,7 @@ def circle(centre=(0, 0), radius=1, resolution=50):
471495

472496

473497
def plot_circle(
474-
radius, centre=(0, 0), *fmt, resolution=50, ax=None, filled=False, **kwargs
498+
radius, centre, *fmt, resolution=50, ax=None, filled=False, **kwargs
475499
):
476500
"""
477501
Plot a circle using matplotlib
@@ -1319,6 +1343,11 @@ def isnotebook():
13191343
if __name__ == "__main__":
13201344
import pathlib
13211345

1346+
1347+
plotvol2(5)
1348+
plot_box(ltrb=[-1, 2, 2, 4], color='r')
1349+
plt.show(block=True)
1350+
13221351
exec(
13231352
open(
13241353
pathlib.Path(__file__).parent.parent.parent.absolute()

0 commit comments

Comments
 (0)
0