예제 #1
0
Vector<T, N> getNearestPoint(const LineSegment<T, N>& line,
                             const Vector<T, N>& point)
{
    double divisor = getLengthSquared(line.getVector());
    double t = (point - line.getStart()) * line.getVector() / divisor;
    return line.getPointAtT(getClamped(t, 0.0, 1.0));
}
예제 #2
0
Vector<T, 2> getRelativePosition(const LineSegment<T, 2>& line,
                                 const Vector<T, 2>& point)
{
    auto lv = line.getVector();
    double len = getLengthSquared(lv);
    auto pv = point - line.getStart();
    return vector2<T>(lv * pv / len, getNormal(lv) * pv / len);
}
예제 #3
0
double getLength(const LineSegment<T, N>& line)
{
    return getLength(line.getVector());
}
예제 #4
0
파일: Line.hpp 프로젝트: jebreimo/JEBLib
 explicit Line(const LineSegment<U, N>& ls)
     : m_Point(ls.getStart()),
       m_Vector(ls.getVector())
 {}