Skip to content

Commit

Permalink
minor doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skramm committed Dec 24, 2023
1 parent 26d8f0a commit 470f93e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions docs/homog2d_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,17 +810,19 @@ auto b2 = p2.isClosed(); // always true
```

Both types provide access to basic attributes:
number of points, number of segments, length, and bounding box, all available as member or free functions:
number of points, number of segments, length and bounding box, all available as member or free functions:
```C++
auto n1 = pl.size(); // nb of points
auto n2 = size(pl);
auto s1 = pl.nbSegs(); // nb of segments
auto s2 = nbSegs(pl);

auto length1 = pl.length(); // or length(pl);
auto rect1 = pl.getBB(); // or getBB(pl);
auto length1 = pl.length(); // or length(pl);
auto rect1 = pl.getBB(); // or getBB(pl);
```

#### 3.4.3 - Extracting data

You can extract either points or segments.
The number of segments is related to the open/close condition.
For example, if we have 4 points, that will generate 4 segments if closed, but only 3 if the polyline is open.
Expand All @@ -832,7 +834,7 @@ auto pt = pl.getPoint( i ); // will throw if point i non-existent
auto seg = pl.getSegment( i ); // will throw if segment i non-existent
```

#### 3.4.3 - Bounding Box and Convex Hull
#### 3.4.4 - Bounding Box and Convex Hull

The `getBB()` member (or free) function returns the corresponding Bounding Box.
this is demonstrated in the following figures for two `Polyline` objects, one closed, the other open.
Expand All @@ -847,7 +849,7 @@ The convex hull of a Polyline can be computed with the member function `convexHu
[see here](#convex-hull-ff) for an example.


#### 3.4.4 - Extremum points
#### 3.4.5 - Extremum points
<a name="poly_extremum_points"></a>

You can get the top-most, left-most, bottom-most, or right-most point with these dedicated member functions:
Expand Down Expand Up @@ -887,7 +889,7 @@ auto right_pt = getExtremePoint( CardDir::Right, pol );

**Warning**: These functions will throw if passed an empty polyline object.

#### 3.4.5 - Distance between two Polyline objects
#### 3.4.6 - Distance between two Polyline objects

You can get the closest distance between two points belonging to two polyline objects with `getClosestPoints()` (free function).
This will return an object on with you can fetch the corresponding pair of points, as indexes or as points, and the distance value:
Expand All @@ -899,9 +901,13 @@ auto pidx = closest.getIndexes(); // get the indexes related to poly1, poly2
```
See [an example here](homog2d_showcase.md#sc14).

#### 3.4.6 - Type of Polyline
#### 3.4.7 - Type of Polyline

You can check if it fullfilths the requirements to be a **simple polygon** (must be closed and no intersections).
<br>
See [definition here](https://en.wikipedia.org/wiki/Simple_polygon)).


You can check if it fullfilths the requirements to be a polygon (must be closed and no intersections).
If it is, you can get its area and its centroid point:
```C++
CPolyline pl;
Expand All @@ -912,6 +918,8 @@ if( pl.isPolygon() ) { // or : if( isPolygon(pl) ) (free function)
}
```

**warning**: function name will change in next release for `isSimple()`

Please note that if not a polygon, or if applied on a open type, then the `area()` function will return 0 but the `centroid()` function will throw.

For closed types, you can determine its convexity:
Expand Down

0 comments on commit 470f93e

Please sign in to comment.