//
// Copyright (C) 2005-2011 by Autodesk, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of version 2.1 of the GNU Lesser
// General Public License as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
#ifndef POINT2D_H_
#define POINT2D_H_
#include "StylizationAPI.h"
#include "StylizationDefs.h"
#include "Vector2D.h"
///
/// A class that represents a two-dimensional point.
///
class Point2D
{
public:
//-------------------------------------------------------
// Constructors
//-------------------------------------------------------
///
/// Initializes a new instance of the Point2D class with
/// the specified coordinates.
///
/// X coordinate of the point.
/// Y coordinate of the point.
STYLIZATION_API Point2D(const double X, const double Y);
///
/// Copy constructor
///
/// The point to be copied.
STYLIZATION_API Point2D(const Point2D& pt);
///
/// Default constructor
///
STYLIZATION_API Point2D();
//-------------------------------------------------------
// Point2D implementation
//-------------------------------------------------------
///
/// Returns whether this point is equal to the supplied point.
///
/// The point to compare to.
/// The tolerance to use when comparing.
/// True if the points are equal; otherwise false.
STYLIZATION_API bool isEqualTo(const Point2D& pt, double tolerance = 1.0e-8) const;
//-------------------------------------------------------
// Operator overloads
//-------------------------------------------------------
///
/// Copy operator
///
/// The point to copy.
/// A reference to this point.
STYLIZATION_API Point2D& operator=(const Point2D& pt);
///
/// Operator that determines whether two points are equal. Two points
/// are equal if they have the same coordinates.
///
/// The point to compare to.
/// True if the points are equal; otherwise false.
STYLIZATION_API bool operator==(const Point2D& pt) const;
///
/// Operator that determines whether two points are unequal. Two points
/// are unequal if they have one or more different coordinates.
///
/// The point to compare to.
/// True if the points are unequal; otherwise false.
STYLIZATION_API bool operator!=(const Point2D& pt) const;
///
/// Operator that adds a vector to a point. The result is a point
/// that is offset from the original point by the vector.
///
/// The vector to add.
/// The result of adding the specified vector to this point.
STYLIZATION_API Point2D operator+(const Vector2D& vec) const;
///
/// Operator that subtracts a vector from a point. The result is a
/// point that is offset from the original point by the vector.
///
/// The vector to subtract.
/// The result of subtracting the specified vector from this point.
STYLIZATION_API Point2D operator-(const Vector2D& vec) const;
///
/// Operator that subtracts two points. The result is a vector going
/// from the second point to the first point.
///
/// The point to subtract.
/// A vector going from the second point to this point.
STYLIZATION_API Vector2D operator-(const Point2D& pt) const;
///
/// Operator to access x, y via indexer. 0 represents the X coordinate of
/// the point, and 1 represents the Y coordinate of the point.
///
/// The indexed x or y value.
STYLIZATION_API double operator[](const unsigned int i) const;
///
/// Operator to access x, y via indexer. 0 represents the X coordinate of
/// the point, and 1 represents the Y coordinate of the point.
///
/// The indexed x or y value.
STYLIZATION_API double& operator[](const unsigned int i);
public:
//-------------------------------------------------------
// Variables
//-------------------------------------------------------
// the coordinates
double x;
double y;
};
#endif