using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VisiMath.Geometry
{

    /// <summary>
    /// Basic type of the convex object (vertex or math equation
    /// </summary>
    public enum ConvexObjectType
    {
        /// <summary>
        /// Math function based (spheres, cylinders)
        /// </summary>
        Implicit,
        /// <summary>
        /// Vertex based
        /// </summary>
        Explicit
    }


    /// <summary>
    /// interface for convex objects for collision solver
    /// </summary>
    public interface IConvexObject
    {

        /// <summary>
        /// Returns implicit (math expression) or explicit (vertex based) type of convex object
        /// </summary>
        ConvexObjectType BaseType { get; }

        /// <summary>
        /// Returns number of vertices, valid for explicit object types
        /// </summary>
        int VertexCount { get; }

        /// <summary>
        /// Returns vertex with specified index, valid for explicit object types
        /// </summary>
        /// <param name="index">index of vertex</param>
        /// <param name="vertex">Vector to save vertex</param>
        void GetVertex(int index, out Vector3 vertex);


        /// <summary>
        /// Returns true if convex object contains position
        /// </summary>
        /// <param name="vec">Position to check</param>
        /// <returns>True if inside</returns>
        bool ContainsPosition(Vector3 vec);
        
        /// <summary>
        /// Gets supporting vertex in local coordinates
        /// </summary>
        /// <param name="vertex">Save vertex</param>
        /// <param name="direction">Direction vector</param>
        void GetLocalSupportingVertex(ref Vector3 direction, out Vector3 vertex);
    }
}
