Example #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));
}
Example #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);
}
Example #3
0
double getLength(const LineSegment<T, N>& line)
{
    return getLength(line.getVector());
}
Example #4
0
 explicit Line(const LineSegment<U, N>& ls)
     : m_Point(ls.getStart()),
       m_Vector(ls.getVector())
 {}