/usr/include/gnash/Point2d.h is in gnash-dev 0.8.11~git20160109-1build1.
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 | // Point2d template - for gnash
//
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// Original author: Sandro Santilli <strk@keybit.net>
//
#ifndef GNASH_POINT2DH
#define GNASH_POINT2DH
#include <ostream>
#include <cmath> // for sqrt()
#include <cstdint>
namespace gnash {
namespace geometry {
/// 2D Point class
//
/// A point which contains a x and a y coorinate in TWIPS.
///
class Point2d
{
public:
/// The x coordinate
std::int32_t x; // TWIPS
/// The y coordinate
std::int32_t y; // TWIPS
/// Construct a Point2d with default x and y coordinates
constexpr Point2d()
:
x(0), y(0)
{
}
/// Construct a Point2d with given x and y ordinates
constexpr Point2d(std::int32_t cx, std::int32_t cy)
:
x(cx), y(cy)
{
}
/// Construct a Point2d as an interpolation of the given input points
//
/// @param p0 first point
/// @param p1 second point
/// @param t interpolation factor, between 0 and 1
///
Point2d(const Point2d& p0, const Point2d& p1, float t)
:
x( p0.x + (std::int32_t)((p1.x - p0.x) * t)),
y( p0.y + (std::int32_t)((p1.y - p0.y) * t))
{
}
/// Set coordinates to given values
//
/// @return a reference to this instance
///
Point2d& setTo(const std::int32_t cx, const std::int32_t cy)
{
x = cx;
y = cy;
return *this;
}
/// Set coordinates to the ones of the interpolation between the given input points
//
/// @param p0 first point
/// @param p1 second point
/// @param t interpolation factor, between 0 and 1
///
/// @return a reference to this instance
///
Point2d& setTo(const Point2d& p0, const Point2d& p1, float t)
{
x = p0.x + (std::int32_t)((p1.x - p0.x) * t);
y = p0.y + (std::int32_t)((p1.y - p0.y) * t);
return *this;
}
/// Return square distance between two given points.
static
std::int64_t squareDistance(const Point2d& p0, const Point2d& p1)
{
std::int64_t hside = p1.x - p0.x;
std::int64_t vside = p1.y - p0.y;
return hside*hside + vside*vside;
}
/// Return square distance between this and the given point
std::int64_t squareDistance(const Point2d& p) const
{
return squareDistance(*this, p);
}
/// Return distance between this and the given point
std::int32_t distance(const Point2d& p) const
{
return (std::int32_t)( std::sqrt( static_cast<double>(squareDistance(p)) ) );
}
bool operator== (const Point2d& p) const
{
return (x == p.x) && (y == p.y);
}
bool operator!=(const Point2d& p) const
{
return ! (*this == p);
}
};
/// Output operator
inline std::ostream&
operator<< (std::ostream& os, const Point2d& p)
{
return os << "Point2d(" << p.x << "," << p.y << ")";
}
} // namespace gnash::geometry
typedef geometry::Point2d point;
} // namespace gnash
#endif // GNASH_POINT2DH
// Local Variables:
// mode: C++
// indent-tabs-mode: t
// End:
|