forked from rai-opensource/spatialmath-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses-2d.html
More file actions
830 lines (772 loc) · 56.3 KB
/
classes-2d.html
File metadata and controls
830 lines (772 loc) · 56.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Geometry — Spatial Maths package 0.11.0
documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/graphviz.css" type="text/css" />
<link rel="shortcut icon" href="_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"TeX": {"Macros": {"presup": ["\\,{}^{\\scriptscriptstyle #1}\\!", 1], "SE": ["\\mathbf{SE}(#1)", 1], "SO": ["\\mathbf{SO}(#1)", 1], "se": ["\\mathbf{se}(#1)", 1], "so": ["\\mathbf{so}(#1)", 1], "vec": ["\\boldsymbol{#1}", 1], "dvec": ["\\dot{\\boldsymbol{#1}}", 1], "ddvec": ["\\ddot{\\boldsymbol{#1}}", 1], "fvec": ["\\presup{#1}\\boldsymbol{#2}", 2], "fdvec": ["\\presup{#1}\\dot{\\boldsymbol{#2}}", 2], "fddvec": ["\\presup{#1}\\ddot{\\boldsymbol{#2}}", 2], "norm": ["\\Vert #1 \\Vert", 1], "mat": ["\\mathbf{#1}", 1], "fmat": ["\\presup{#1}\\mathbf{#2}", 2], "sk": ["\\left[#1\\right]", 1], "skx": ["\\left[#1\\right]_{\\times}", 1], "vex": ["\\vee\\left( #1\\right)", 1], "vexx": ["\\vee_{\\times}\\left( #1\\right)", 1], "q": "\\mathring{q}", "fq": ["\\presup{#1}\\mathring{q}", 1]}}})</script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Spatial Maths package
<img src="_static/CartesianSnakes_LogoW.png" class="logo" alt="Logo"/>
</a>
<div class="version">
0.9
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="spatialmath.html">Class reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="functions.html">Function reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="indices.html">Indices</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Spatial Maths package</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li>Geometry</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/classes-2d.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="module-spatialmath.geom2d">
<span id="geometry"></span><h1>Geometry<a class="headerlink" href="#module-spatialmath.geom2d" title="Permalink to this headline"></a></h1>
<p>Created on Sun Jul 5 09:42:30 2020</p>
<p>@author: corkep</p>
<dl class="py class">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Polygon2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vertices</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Class to represent 2D (planar) polygons</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Uses Matplotlib primitives to perform transformations and
intersections.</p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vertices</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.__init__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.__init__" title="Permalink to this definition"></a></dt>
<dd><p>Create planar polygon from vertices</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>vertices</strong> (<em>ndarray</em><em>(</em><em>2</em><em>, </em><em>N</em><em>)</em><em>, </em><em>optional</em>) – vertices of polygon, defaults to None</p>
</dd>
</dl>
<p>Create a polygon from a set of points provided as columns of the 2D
array <code class="docutils literal notranslate"><span class="pre">vertices</span></code>.
A closed polygon is created so the last vertex should not equal the
first.</p>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The points must be sequential around the perimeter and
counter clockwise.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The polygon is represented by a Matplotlib <code class="docutils literal notranslate"><span class="pre">Path</span></code></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.plot">
<span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.plot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.plot" title="Permalink to this definition"></a></dt>
<dd><p>Plot polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ax</strong> (<em>Axes</em><em>, </em><em>optional</em>) – axes in which to draw the polygon, defaults to None</p></li>
<li><p><strong>kwargs</strong> – options passed to Matplotlib <code class="docutils literal notranslate"><span class="pre">Patch</span></code></p></li>
</ul>
</dd>
</dl>
<p>A Matplotlib Patch is created with the passed options <code class="docutils literal notranslate"><span class="pre">**kwargs</span></code> and
added to the axes.</p>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p><a class="reference internal" href="#spatialmath.geom2d.Polygon2.animate" title="spatialmath.geom2d.Polygon2.animate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">animate()</span></code></a> <code class="xref py py-func docutils literal notranslate"><span class="pre">matplotlib.PathPatch()</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.animate">
<span class="sig-name descname"><span class="pre">animate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.animate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.animate" title="Permalink to this definition"></a></dt>
<dd><p>Animate a polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>T</strong> (<a class="reference internal" href="2d_pose_SE2.html#spatialmath.pose2d.SE2" title="spatialmath.pose2d.SE2"><em>SE2</em></a>) – new pose of Polygon</p></li>
<li><p><strong>kwargs</strong> – options passed to Matplotlib <code class="docutils literal notranslate"><span class="pre">Patch</span></code></p></li>
</ul>
</dd>
</dl>
<p>The plotted polygon is moved to the pose given by <code class="docutils literal notranslate"><span class="pre">T</span></code>. The pose is
always with respect to the initial vertices when the polygon was
constructed. The vertices of the polygon will be updated to reflect
what is plotted.</p>
<p>If the polygon has already plotted, it will keep the same graphical
attributes. If new attributes are given they will replace those
given at construction time.</p>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p><a class="reference internal" href="#spatialmath.geom2d.Polygon2.plot" title="spatialmath.geom2d.Polygon2.plot"><code class="xref py py-meth docutils literal notranslate"><span class="pre">plot()</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.contains">
<span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.contains"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.contains" title="Permalink to this definition"></a></dt>
<dd><p>Test if point is inside polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p</strong> (<em>array_like</em><em>(</em><em>2</em><em>)</em>) – point</p></li>
<li><p><strong>radius</strong> (<em>float</em><em>, </em><em>optional</em>) – Add an additional margin to the polygon boundary, defaults to 0.0</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if point is contained by polygon</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">radius</span></code> can be used to inflate the polygon, or if negative, to
deflated it.</p>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Returns True if the point is on the edge of the polygon
but False if the point is one of the vertices.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>For a polygon with clockwise ordering of vertices the
sign of <code class="docutils literal notranslate"><span class="pre">radius</span></code> is flipped.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p><code class="xref py py-func docutils literal notranslate"><span class="pre">matplotlib.contains_point()</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.bbox">
<span class="sig-name descname"><span class="pre">bbox</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.bbox"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.bbox" title="Permalink to this definition"></a></dt>
<dd><p>Bounding box of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>bounding box as [xmin, xmax, ymin, ymax]</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>ndarray(4)</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.radius">
<span class="sig-name descname"><span class="pre">radius</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.radius"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.radius" title="Permalink to this definition"></a></dt>
<dd><p>Radius of smallest enclosing circle</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>radius</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
<p>This is the radius of the smalleset circle, centred at the centroid,
that encloses all vertices.</p>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.intersects">
<span class="sig-name descname"><span class="pre">intersects</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.intersects"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.intersects" title="Permalink to this definition"></a></dt>
<dd><p>Test for intersection</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>other</strong> (<a class="reference internal" href="#spatialmath.geom2d.Polygon2" title="spatialmath.geom2d.Polygon2"><em>Polygon2</em></a><em> or </em><a class="reference internal" href="#spatialmath.geom2d.Line2" title="spatialmath.geom2d.Line2"><em>Line2</em></a>) – object to test for intersection</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if the polygon intersects <code class="docutils literal notranslate"><span class="pre">other</span></code></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.transformed">
<span class="sig-name descname"><span class="pre">transformed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">T</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.transformed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.transformed" title="Permalink to this definition"></a></dt>
<dd><p>A transformed copy of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>T</strong> (<a class="reference internal" href="2d_pose_SE2.html#spatialmath.pose2d.SE2" title="spatialmath.pose2d.SE2"><em>SE2</em></a>) – planar transformation</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>transformed polygon</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#spatialmath.geom2d.Polygon2" title="spatialmath.geom2d.Polygon2">Polygon2</a></p>
</dd>
</dl>
<p>Returns a new polgyon whose vertices have been transformed by <code class="docutils literal notranslate"><span class="pre">T</span></code>.</p>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.area">
<span class="sig-name descname"><span class="pre">area</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.area"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.area" title="Permalink to this definition"></a></dt>
<dd><p>Area of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>area</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>For a polygon with clockwise ordering of vertices the
area will be negative.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p><a class="reference internal" href="#spatialmath.geom2d.Polygon2.moment" title="spatialmath.geom2d.Polygon2.moment"><code class="xref py py-meth docutils literal notranslate"><span class="pre">moment()</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.centroid">
<span class="sig-name descname"><span class="pre">centroid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.centroid"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.centroid" title="Permalink to this definition"></a></dt>
<dd><p>Centroid of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>centroid</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>ndarray(2)</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p><a class="reference internal" href="#spatialmath.geom2d.Polygon2.moment" title="spatialmath.geom2d.Polygon2.moment"><code class="xref py py-meth docutils literal notranslate"><span class="pre">moment()</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.vertices">
<span class="sig-name descname"><span class="pre">vertices</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">closed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.vertices"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.vertices" title="Permalink to this definition"></a></dt>
<dd><p>Vertices of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>closed</strong> (<em>bool</em><em>, </em><em>optional</em>) – include first vertex twice, defaults to False</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>vertices</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>ndarray(2,n)</p>
</dd>
</dl>
<p>Returns the set of vertices. If <code class="docutils literal notranslate"><span class="pre">closed</span></code> is True then the last
column is the same as the first, that is, the polygon is explicitly
closed.</p>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.edges">
<span class="sig-name descname"><span class="pre">edges</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.edges"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.edges" title="Permalink to this definition"></a></dt>
<dd><p>Iterate over polygon edge segments</p>
<p>Creates an iterator that returns pairs of points representing the
end points of each segment.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Polygon2.moment">
<span class="sig-name descname"><span class="pre">moment</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Polygon2.moment"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Polygon2.moment" title="Permalink to this definition"></a></dt>
<dd><p>Moments of polygon</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p</strong> (<em>int</em>) – moment order x</p></li>
<li><p><strong>q</strong> (<em>int</em>) – moment order y</p></li>
</ul>
</dd>
</dl>
<p>Returns the pq’th moment of the polygon</p>
<div class="math notranslate nohighlight">
\[M(p, q) = \sum_{i=0}^{n-1} x_i^p y_i^q\]</div>
<p>Example:</p>
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/path.py", line 130, in __init__</span>
<span class="go"> _api.check_shape((None, 2), vertices=vertices)</span>
<span class="go"> File "/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/matplotlib/_api/__init__.py", line 165, in check_shape</span>
<span class="go"> f"{k!r} must be {len(target_shape)}D "</span>
<span class="go">ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (3, 3).</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<input>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
<span class="gr">NameError</span>: <span class="n">name 'p' is not defined</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Line2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Class to represent 2D lines</p>
<p>The internal representation is in homogeneous format</p>
<div class="math notranslate nohighlight">
\[ax + by + c = 0\]</div>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.__init__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.__init__" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.TwoPoints">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">TwoPoints</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.TwoPoints"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.TwoPoints" title="Permalink to this definition"></a></dt>
<dd><p>Create 2D line from two points</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – point on the line</p></li>
<li><p><strong>p2</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – another point on the line</p></li>
</ul>
</dd>
</dl>
<p>The points can be given in Euclidean or homogeneous form.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.General">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">General</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.General"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.General" title="Permalink to this definition"></a></dt>
<dd><p>Create line from general line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>m</strong> (<em>float</em>) – line gradient</p></li>
<li><p><strong>c</strong> (<em>float</em>) – line intercept</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>a 2D line</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>a Line2 instance</p>
</dd>
</dl>
<p>Creates a line from the parameters of the general line <span class="math notranslate nohighlight">\(y = mx + c\)</span>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>A vertical line cannot be represented.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.general">
<span class="sig-name descname"><span class="pre">general</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.general"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.general" title="Permalink to this definition"></a></dt>
<dd><p>Parameters of general line</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>parameters of general line (m, c)</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>ndarray(2)</p>
</dd>
</dl>
<p>Return the parameters of a general line <span class="math notranslate nohighlight">\(y = mx + c\)</span>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.plot">
<span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.plot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.plot" title="Permalink to this definition"></a></dt>
<dd><p>Plot the line using matplotlib</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>kwargs</strong> – arguments passed to Matplotlib <code class="docutils literal notranslate"><span class="pre">pyplot.plot</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.intersect">
<span class="sig-name descname"><span class="pre">intersect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.intersect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.intersect" title="Permalink to this definition"></a></dt>
<dd><p>Intersection with line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>other</strong> (<a class="reference internal" href="#spatialmath.geom2d.Line2" title="spatialmath.geom2d.Line2"><em>Line2</em></a>) – another 2D line</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>intersection point in homogeneous form</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>ndarray(3)</p>
</dd>
</dl>
<p>If the lines are parallel then the third element of the returned
homogeneous point will be zero (an ideal point).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.contains">
<span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.contains"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.contains" title="Permalink to this definition"></a></dt>
<dd><p>Test if point is in line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – point to test</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if point lies in the line</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.intersect_segment">
<span class="sig-name descname"><span class="pre">intersect_segment</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.intersect_segment"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.intersect_segment" title="Permalink to this definition"></a></dt>
<dd><p>Test for line intersecting line segment</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – start of line segment</p></li>
<li><p><strong>p2</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – end of line segment</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if they intersect</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
<p>Tests whether the line intersects the line segment defined by endpoints
<code class="docutils literal notranslate"><span class="pre">p1</span></code> and <code class="docutils literal notranslate"><span class="pre">p2</span></code> which are given in Euclidean or homogeneous form.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.distance_line_line">
<span class="sig-name descname"><span class="pre">distance_line_line</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.distance_line_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.distance_line_line" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.distance_line_point">
<span class="sig-name descname"><span class="pre">distance_line_point</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.distance_line_point"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.distance_line_point" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.points_join">
<span class="sig-name descname"><span class="pre">points_join</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.points_join"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.points_join" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.intersect_polygon___line">
<span class="sig-name descname"><span class="pre">intersect_polygon___line</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.intersect_polygon___line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.intersect_polygon___line" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.Line2.contains_polygon_point">
<span class="sig-name descname"><span class="pre">contains_polygon_point</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#Line2.contains_polygon_point"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.Line2.contains_polygon_point" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">LineSegment2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/spatialmath/geom2d.html#LineSegment2"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#spatialmath.geom2d.LineSegment2" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#spatialmath.geom2d.Line2" title="spatialmath.geom2d.Line2"><code class="xref py py-class docutils literal notranslate"><span class="pre">spatialmath.geom2d.Line2</span></code></a></p>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.General">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">General</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.General" title="Permalink to this definition"></a></dt>
<dd><p>Create line from general line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>m</strong> (<em>float</em>) – line gradient</p></li>
<li><p><strong>c</strong> (<em>float</em>) – line intercept</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>a 2D line</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>a Line2 instance</p>
</dd>
</dl>
<p>Creates a line from the parameters of the general line <span class="math notranslate nohighlight">\(y = mx + c\)</span>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>A vertical line cannot be represented.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.TwoPoints">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">TwoPoints</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.TwoPoints" title="Permalink to this definition"></a></dt>
<dd><p>Create 2D line from two points</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – point on the line</p></li>
<li><p><strong>p2</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – another point on the line</p></li>
</ul>
</dd>
</dl>
<p>The points can be given in Euclidean or homogeneous form.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.__init__" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.contains">
<span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.contains" title="Permalink to this definition"></a></dt>
<dd><p>Test if point is in line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – point to test</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if point lies in the line</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.contains_polygon_point">
<span class="sig-name descname"><span class="pre">contains_polygon_point</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.contains_polygon_point" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.distance_line_line">
<span class="sig-name descname"><span class="pre">distance_line_line</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.distance_line_line" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.distance_line_point">
<span class="sig-name descname"><span class="pre">distance_line_point</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.distance_line_point" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.general">
<span class="sig-name descname"><span class="pre">general</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.general" title="Permalink to this definition"></a></dt>
<dd><p>Parameters of general line</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>parameters of general line (m, c)</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>ndarray(2)</p>
</dd>
</dl>
<p>Return the parameters of a general line <span class="math notranslate nohighlight">\(y = mx + c\)</span>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.intersect">
<span class="sig-name descname"><span class="pre">intersect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.intersect" title="Permalink to this definition"></a></dt>
<dd><p>Intersection with line</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>other</strong> (<a class="reference internal" href="#spatialmath.geom2d.Line2" title="spatialmath.geom2d.Line2"><em>Line2</em></a>) – another 2D line</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>intersection point in homogeneous form</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>ndarray(3)</p>
</dd>
</dl>
<p>If the lines are parallel then the third element of the returned
homogeneous point will be zero (an ideal point).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.intersect_polygon___line">
<span class="sig-name descname"><span class="pre">intersect_polygon___line</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.intersect_polygon___line" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.intersect_segment">
<span class="sig-name descname"><span class="pre">intersect_segment</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.intersect_segment" title="Permalink to this definition"></a></dt>
<dd><p>Test for line intersecting line segment</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>p1</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – start of line segment</p></li>
<li><p><strong>p2</strong> (<em>array_like</em><em>(</em><em>2</em><em>) or </em><em>array_like</em><em>(</em><em>3</em><em>)</em>) – end of line segment</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if they intersect</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
<p>Tests whether the line intersects the line segment defined by endpoints
<code class="docutils literal notranslate"><span class="pre">p1</span></code> and <code class="docutils literal notranslate"><span class="pre">p2</span></code> which are given in Euclidean or homogeneous form.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.plot">
<span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.plot" title="Permalink to this definition"></a></dt>
<dd><p>Plot the line using matplotlib</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>kwargs</strong> – arguments passed to Matplotlib <code class="docutils literal notranslate"><span class="pre">pyplot.plot</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="spatialmath.geom2d.LineSegment2.points_join">
<span class="sig-name descname"><span class="pre">points_join</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#spatialmath.geom2d.LineSegment2.points_join" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</section>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>© Copyright 2020, Peter Corke.
<span class="lastupdated">Last updated on 26-Nov-2021.
</span></p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
<!-- Theme Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-11Q6WJM565"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-11Q6WJM565', {
'anonymize_ip': false,
});
</script>
</body>
</html>