Hermes
Loading...
Searching...
No Matches
segment.h
1#ifndef HERMES_GEOMETRY_SEGMENT_H
2#define HERMES_GEOMETRY_SEGMENT_H
3
5
6namespace hermes {
7
8/* Line segment **ab**
9 */
10template<typename T> class Segment {
11public:
12 Segment() {}
13 Segment(T _a, T _b) : a(_a), b(_b) {}
14 virtual ~Segment() {}
15
16 float length() const { return (b - a).length(); }
17
18 float length2() const { return (b - a).length2(); }
19 T &operator[](size_t i) { return (i == 0) ? a : b; }
20 T a, b;
21};
22
25
26} // hermes namespace
27
28#endif // HERMES_GEOMETRY_SEGMENT_H
Definition segment.h:10
Geometric point classes.
Holds 2-dimensional integer index coordinates.
Definition index.h:50