Ejemplo n.º 1
0
    public override optional <float> Distance(Vector3 to, Vector3 from, float radius)    //distance is Euclidean but is (guaranteed?) to be sorted correctly with the current assertions about speed vs player_radius
    {
        optional <Vector3> point        = SphereUtility.Intersection(from, to, Center(radius), AngularRadius(radius));
        optional <float>   intersection = new optional <float>();

        if (point.exists)
        {
            intersection = CartesianToRadial(point.data);
        }

        if (intersection.exists)
        {
            float   angle        = intersection.data;
            Vector3 new_position = Evaluate(angle, radius);
            return((from - new_position).sqrMagnitude);            //CONSIDER: does Cartesian distance matter?
        }

        return(new optional <float>());
    }
Ejemplo n.º 2
0
    /** Find the point of collision with an arc.
     */
    public optional <Vector3> Intersect(Vector3 to, Vector3 from, float radius)
    {
        optional <Vector3> result = SphereUtility.Intersection(from, to, Pole(), AngularRadius(radius));

        return(result);
    }