Matlab/Octave computational geometry functions

Rename quat2rotm to q2rotm

Add angle functions

96cbf827
—
Sotiris Papatheodorou
3 years ago

Fix the README image path

- read-only
- https://git.sr.ht/~sotirisp/G-mfunctions
- read/write
- git@git.sr.ht:~sotirisp/G-mfunctions

A collection of useful Matlab functions for version 2016b or later. They are mainly helper functions to make working with polygons easier.

To use these functions in your code add the `Functions`

folder in your Matlab
path. For example

```
addpath(genpath('~/Documents/G-mfunctions/Functions'));
```

All functions are documented in the standard Matlab style and their help is
available using `help [function name]`

. An example plot created from functions
in G-mfunctions can be seen below.

These functions implement common operations on polygons, circles and ellipses.
There are also functions to easily plot and fill these shapes with syntax
similar to `plot`

and `fill`

.

These functions implement several 2D space partitioning schemes. All functions in the Partitioning folder compute the cell of a single generator. The following partitioning methods have been implemented:

`cellvoronoi`

: Voronoi diagram`cellgvoronoi`

: Guaranteed Voronoi diagram, presented in [R1]`cellwgvoronoi`

: Additively Weighted Guaranteed Voronoi diagram`cellpower`

: Power diagram`cellsensing`

: Sensing pattern partitioning presented in [R2]

More general functions not fitting in the aforementioned categories.

Before Matlab 2017b, polygons were represented in two ways. The first
representation consists of two lists of vertices, one for the `x`

and one for
the `y`

coordinates, with contours being separated by NaNs. The second
representation consists of two cell arrays, one for the `x`

and one for the `y`

coordinates, with each cell containing the vertices of a single contour.
External contours have clockwise ordered vertices while internal contours have
counterclockwise ordered vertices. The functions in this repository use the
first representation due to its increased speed when performing boolean polygon
operations. Two functions, `polycell2nan`

and `polynan2cell`

, are provided to
convert polygons from one representation to the other.

Since Matlab R2017b the `polyshape`

function is available which allows creating
polygon objects and several of the functions present in this repository have
been implemented as object functions. At some point I might extend some
functions to accept polyshape objects but pull requests are also welcome. It
should be also noted that boolean polygon operations using polyshape objects
are faster than using polybool as can be seen in `Tests/benchmarks.m`

.

[R1] W. Evans and J. Sember, *Guaranteed voronoi diagrams of uncertain
sites*, In Proceedings of the
20th Canadian Conference on Computational Geometry (CCCG), pp. 207-210, August
13 - 15, 2008, Montreal, Canada

[R2] Y. Stergiopoulos and A. Tzes, *Cooperative positioning/orientation
control of mobile heterogeneous anisotropic sensor networks for area
coverage*, In Proceedings of the
2014 IEEE International Conference on Robotics and Automation (ICRA), pp.
1106-1111, May 31 - June 7, 2014, Hong Kong, China

Copyright © 2016-2018 Sotiris Papatheodorou

Distributed under the Apache License Version 2.0