/usr/include/geos/geom/LineSegment.inl is in libgeos-dev 3.2.2-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /**********************************************************************
* $Id: LineSegment.inl 2345 2009-04-10 12:08:18Z strk $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* Copyright (C) 2009 Sandro Santilli <strk@keybit.net>
* Copyright (C) 2005-2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: geom/LineSegment.java rev. 1.30 (JTS-1.9)
*
**********************************************************************/
#ifndef GEOS_LINESEGMENT_INL
#define GEOS_LINESEGMENT_INL
#include <geos/geom/LineSegment.h>
#include <geos/algorithm/CGAlgorithms.h>
#include <cassert>
#include <cmath> // for atan2
namespace geos {
namespace geom { // geos::geom
INLINE
LineSegment::LineSegment(const LineSegment& ls)
:
p0(ls.p0),
p1(ls.p1)
{
}
INLINE
LineSegment::LineSegment(const Coordinate& c0, const Coordinate& c1)
:
p0(c0),
p1(c1)
{
}
INLINE
LineSegment::LineSegment(double x0, double y0, double x1, double y1)
:
p0(x0, y0),
p1(x1, y1)
{
}
INLINE
LineSegment::LineSegment()
{
}
INLINE
LineSegment::~LineSegment()
{
}
INLINE double
LineSegment::distancePerpendicular(const Coordinate& p) const
{
return algorithm::CGAlgorithms::distancePointLinePerpendicular(p, p0, p1);
}
INLINE void
LineSegment::pointAlong(double segmentLengthFraction, Coordinate& ret) const
{
ret = Coordinate(
p0.x + segmentLengthFraction * (p1.x - p0.x),
p0.y + segmentLengthFraction * (p1.y - p0.y));
}
INLINE double
LineSegment::distance(const LineSegment& ls) const
{
return algorithm::CGAlgorithms::distanceLineLine(p0, p1, ls.p0, ls.p1);
}
/*public*/
INLINE double
LineSegment::distance(const Coordinate& p) const
{
return algorithm::CGAlgorithms::distancePointLine(p, p0, p1);
}
INLINE void
LineSegment::normalize()
{
if (p1.compareTo(p0)<0) reverse();
}
INLINE void
LineSegment::setCoordinates(const Coordinate& c0, const Coordinate& c1)
{
p0=c0; p1=c1;
}
INLINE const Coordinate&
LineSegment::operator[](size_t i) const
{
if (i==0) return p0;
assert(i==1);
return p1;
}
INLINE Coordinate&
LineSegment::operator[](size_t i)
{
if (i==0) return p0;
assert(i==1);
return p1;
}
INLINE void
LineSegment::setCoordinates(const LineSegment& ls)
{
setCoordinates(ls.p0,ls.p1);
}
INLINE double
LineSegment::getLength() const
{
return p0.distance(p1);
}
INLINE bool
LineSegment::isHorizontal() const
{
return p0.y == p1.y;
}
INLINE bool
LineSegment::isVertical() const
{
return p0.x == p1.x;
}
INLINE int
LineSegment::orientationIndex(const LineSegment* seg) const
{
assert(seg);
return orientationIndex(*seg);
}
INLINE int
LineSegment::orientationIndex(const Coordinate& p) const
{
return algorithm::CGAlgorithms::orientationIndex(p0, p1, p);
}
INLINE CoordinateSequence*
LineSegment::closestPoints(const LineSegment* line)
{
assert(line);
return closestPoints(*line);
}
INLINE double
LineSegment::angle() const
{
return std::atan2(p1.y-p0.y,p1.x-p0.x);
}
INLINE void
LineSegment::midPoint(Coordinate& ret) const
{
ret = Coordinate( (p0.x + p1.x) / 2,
(p0.y + p1.y) / 2 );
}
INLINE std::ostream&
operator<< (std::ostream& o, const LineSegment& l)
{
return o<<"LINESEGMENT("<<l.p0.x<<" "<<l.p0.y<<","<<l.p1.x<<" "<<l.p1.y<<")";
}
INLINE bool
operator==(const LineSegment& a, const LineSegment& b)
{
return a.p0==b.p0 && a.p1==b.p1;
}
} // namespace geos::geom
} // namespace geos
#endif // GEOS_LINESEGMENT_INL
|