// Gnurbs - A curve and surface library
// Copyright (C) 2008-2026 Eric Bechet
//
// See the LICENSE file for contributions and license information.
// Please report all bugs and problems to <bechet@cadxfem.org>.
//

#ifndef __NCLOTHOID_H
#define __NCLOTHOID_H

#include "gnurbsconfig.h"

#ifdef ENABLE_CLOTHOID
#include "ncurve.h"
#include "Clothoid.hh"

/// An Euler spiral.
class nclothoid : public nparametriccurve
{

public:
  nclothoid() {}
  nclothoid(npoint2 P0,double theta0,npoint2 P1,double theta1);
  /// \brief Returns the degree of the curve (if polynomial).
  /// \return Curve degree.
  virtual int degree(void) const {return 2;}

  /// \brief Minimum allowed value of the parameter.
  /// \return Minimum allowed value of the parameter.
  virtual double min_u(void) const;

  /// \brief Maximum allowed value of the parameter.
  /// \return Maximum allowed value of the parameter.
  virtual double max_u(void) const;

  /// \brief Point along the curve for parameter u.
  /// \param[in] u parameter.
  /// \param[out] ret point corresponding to parameter u.
  virtual void P(double u,npoint& ret) const;

  /// \brief First derivative
  /// \param[in] u_ parameter.
  /// \param[out] ret first derivative at parameter u_.
  virtual void dPdu(double u_,npoint& ret) const;

  /// \brief Second derivative
  /// \param[in] u_ parameter.
  /// \param[out] ret second derivative at parameter u_.
  virtual void d2Pdu2(double u_,npoint& ret) const;

  /// \brief Second derivative (one over radius of curvature).
  /// \param[in] u_ parameter.
  /// \return Second derivative.
  virtual double Kappa(double u_) const;
  
  virtual nclothoid* clone() const
  {
    return new nclothoid(*this);
  }
private:
    G2lib::ClothoidCurve Cl;
};

#endif //ENABLE_CLOTHOID

#endif //__NCLOTHOID_H
