#ifndef D2ARROW_H
#define D2ARROW_H

#include <print.h>
#include <point.h>
#include <gobj.h>


/*!
  \brief Arrow in 2D to aid in visualization.

  The arrow can be constructed in several ways. The simplest is along
  the x-axis where I would then use OpenGL to do the transformations.
  A normal can be constructed given two points which is really useful.
  The standard generic position and angle is there too. 

  The arrows geometric points are public so if the client wishes
  to use this class efficiently they should directly apply any 
  transforms to the points and call draw() rather than using this
  classes transformations.
  

  Arrow point geometry for pi[].

                    2
                     \
                      \
  0 -------------------- 1
                      /
                     /
                    3
  arrowlength = distance(0,1)
  headlength = the distance from 1 to intersecting line (2,3)
  head height = distance(2,3)
*/
class d2arrow : public gobj
{
public:

  /** Arrow geometry */
  point2<double> pi[4];

  /** Change how fat or thin the arrow head is.  This multiplied by
      the headlength gives the height of the arrow head. */
  static double headlengthfactor;


  /** Construct an arrow along the x-axis. */
  d2arrow( doublec arrowlength, doublec headlength );

  /** Construct an arrow at the point and rotate it. */
  d2arrow
  (
    point2<double> const & pi0,
    doublec theta, 
    doublec arrowlength, 
    doublec headlength
  );

  /** Construct a normal. The arrow is rotated 90 degrees to line 
      (q0,q1) with the base of the arrow in between q0 and q1. */
  d2arrow
  (
    point2<double> const & q0,
    point2<double> const & q1,
    doublec arrowlength, 
    doublec headlength
  );

  /** Draw the arrow. */
  void draw();

  /** Rotate the arrow about pi[0] by theta radians. */
  void rotate(doublec theta);

  /** Shift the arrow by x. */
  void translate( point2<double> const & x );

  /**  Construct an arrow along the x-axis. */
  void constructOnXaxis( doublec arrowlength, doublec headlength );
};


#endif




