// $Source: /local/data/cvs/yellowbank/tile/qtransform.h,v $
// $Revision: 1.3 $
// $State: Exp $
// $Date: 2004/07/19 03:54:07 $
// $Author: yrp001 $
// $Locker:  $

// Two dimensional point tranformations
// 
// Working
// 
// (Nice idea, but deferred...)
// Maintain queue of elementary transformations, and
// a current transformation which is the result of applying
// all of the elementary transformations in succession.
// 
// Maintaining the elementary transformations allows for future
// edits or deletions of previous transformations.


#if !defined(_QTRANSFORM_H_)
#define _QTRANSFORM_H_

#include <iostream>
#include <math.h>
#include "qpoint.h"
#include "qedge.h"

class qtransform
{
 public:
  // constructor(s) and destructor;
  qtransform();
  qtransform( const qtransform& other );

 private:
  qtransform( double* tm );

 public:

  // interface
  //
  // the current transformation matrix is calculated by multiplying
  // the existing transformation matrix by the the transformation matrix
  // corresponding to the indicated primitive transformation.
  // (new current = primitive x current)
  //
  void reset();
  void translate( const qpoint& p );
  void translate( double tx, double ty );
  void scale( double sx, double sy );
  void scale( double s ) { scale( s, s ); }
  void rotate( double angrad );
  void rotate( const qpoint& pt, double angrad );
  void rotate( double x, double y, double angrad );
  void mirrorx();
  void mirror( double angrad );
  void mirror( const qpoint& pt, double angrad );
  void mirror( double x, double y, double angrad );
  void mirror( const qpoint& p1, const qpoint& p2 );
  void mirror( const qedge& e );
  void skewx( double skx );
  void skewy( double sky );

  int operator==( const qtransform& rhs ) const;

  qtransform& operator=( const qtransform& rhs );
  qtransform operator*( const qtransform& rhs ) const;
  qpoint operator*( const qpoint& rhs ) const; // non-transitive.  left-to-right

  friend std::ostream& operator<<( std::ostream& os, qtransform& t );
  friend std::istream& operator>>( std::istream& is, qtransform& t );

 private:
  double _tm[3][3]; // transformation matrix
};

#endif



