#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_GENERATORS_LINE3GENERATOR_H
#define NUCLEX_GEOMETRY_LINES_GENERATORS_LINE3GENERATOR_H
#include "Nuclex/Geometry/Config.h"
#include "Nuclex/Geometry/Lines/Line3.h"
namespace Nuclex { namespace Geometry { namespace Lines { namespace Generators {
// ------------------------------------------------------------------------------------------- //
/// Point and area generation methods for 3D lines
template
class Line3Generator {
/// Determines the closest point to another point upon the line
/// Line on which the closest point will be found
/// Point to which the closest point will be determined
/// The closest point to the specified point upon the line
public: static Point3 GetClosestPointUpon(
const Line3 &line, const Point3 &point
) {
Vector3 offset = point - line.Origin;
TScalar t = Vector3::Dot(line.Direction, offset);
return line.Origin + (line.Direction * t);
}
};
// ------------------------------------------------------------------------------------------- //
}}}} // namespace Nuclex::Geometry::Lines::Generators
#endif // NUCLEX_GEOMETRY_LINES_GENERATORS_LINE3GENERATOR_H