Ejemplo n.º 1
0
RNLength R2Distance(const R2Point& point, const R2Ray& ray)
{
    // Check if start point is closest
    R2Vector v = point - ray.Start();
    RNScalar dir = v.Dot(ray.Vector());
    if (RNIsNegative(dir)) return v.Length();

    // Return distance from point to ray line
    return R2Distance(point, ray.Line());
}
Ejemplo n.º 2
0
RNLength R2SquaredDistance(const R2Point& point1, const R2Point& point2)
{
    // Return squared length of vector between points
    R2Vector v = point1 - point2;
    return v.Dot(v);
}