#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2015 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GEOMETRY_LINES_RAY2_H #define NUCLEX_GEOMETRY_LINES_RAY2_H #include "Nuclex/Geometry/Config.h" #include "Nuclex/Geometry/Point2.h" #include "Nuclex/Geometry/Vector2.h" namespace Nuclex { namespace Geometry { namespace Lines { // ------------------------------------------------------------------------------------------- // /// 2D ray defined by a starting point and a direction template struct Ray2 { /// Initializes a ray using the specified coordinates /// Position at which the ray begins /// Direction into which the ray extends public: Ray2(const Point2 &origin, const Vector2 &direction) : Origin(origin), Direction(direction) {} /// Offsets the entire ray by the specified amount /// Amount the ray will be offset on the X axis /// Amount the ray will be offset on the Y axis public: void ShiftBy(TScalar offsetX, TScalar offsetY) { this->Origin.X += offsetX; this->Origin.Y += offsetY; } /// Offsets the entire ray by the specified amount /// Amount the ray will be offset public: void ShiftBy(const Vector2 &offset) { this->Origin += offset; } /// Coordinates at which the ray begins public: Point2 Origin; /// Direction into which the ray entends public: Vector2 Direction; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Geometry::Lines #endif // NUCLEX_GEOMETRY_LINES_RAY2_H