305 lines
10 KiB
C++
305 lines
10 KiB
C++
|
|
// -*- C++ -*-
|
|
|
|
|
|
namespace Hurricane {
|
|
|
|
/*! \class Transformation
|
|
* \brief Transformation description (\b API)
|
|
*
|
|
* \section secTransformationIntro Introduction
|
|
*
|
|
* Transformation objects are a combination of a
|
|
* <b>translation</b> and an <b>orientation</b> defined by the
|
|
* new enumeration <b>Transformation::Orientation</b> whose
|
|
* different values are described in table below.
|
|
*
|
|
*
|
|
* \remark <b>Rotations are done counter clock wise</b> :
|
|
*/
|
|
|
|
|
|
|
|
/*! \class Transformation::Orientation
|
|
* This enumeration defines the orientation associated to a
|
|
* transformation object.
|
|
* <TABLE>
|
|
* <CAPTION>Orientation codes and associated transformation matrix</CAPTION>
|
|
* <TR>
|
|
* <TD>Name</TD><TD>Aspect</TD><TD>Code</TD><TD>Signification</TD><TD>a</TD><TD>b</TD><TD>c</TD><TD>d</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>ID</TD>
|
|
* <TD>
|
|
* \image html id.gif
|
|
* </TD>
|
|
* <TD>0</TD><TD>Identity</TD>
|
|
* <TD>1</TD><TD>0</TD><TD>0</TD><TD>1</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>R1</TD>
|
|
* <TD>
|
|
* \image html r1.gif
|
|
* </TD>
|
|
* <TD>1</TD><TD>Simple rotation (90°)</TD>
|
|
* <TD>0</TD><TD>-1</TD><TD>1</TD><TD>0</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>R2</TD>
|
|
* <TD>
|
|
* \image html r2.gif
|
|
* </TD>
|
|
* <TD>2</TD><TD>Double rotation (180°)</TD>
|
|
* <TD>-1</TD><TD>0</TD><TD>0</TD><TD>-1</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>R3</TD>
|
|
* <TD>
|
|
* \image html r3.gif
|
|
* </TD>
|
|
* <TD>3</TD><TD>Triple rotation (270°)</TD>
|
|
* <TD>0</TD><TD>1</TD><TD>-1</TD><TD>0</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>MX</TD>
|
|
* <TD>
|
|
* \image html mx.gif
|
|
* </TD>
|
|
* <TD>4</TD><TD>Horizontal symetry (Mirror X)</TD>
|
|
* <TD>-1</TD><TD>0</TD><TD>0</TD><TD>1</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>XR</TD>
|
|
* <TD>
|
|
* \image html xr.gif
|
|
* </TD>
|
|
* <TD>5</TD><TD>Horizontal symetry followed by a 90° rotation</TD>
|
|
* <TD>0</TD><TD>-1</TD><TD>-1</TD><TD>0</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>MY</TD>
|
|
* <TD>
|
|
* \image html my.gif
|
|
* </TD>
|
|
* <TD>6</TD><TD>Vertical symetry (Mirror Y)</TD>
|
|
* <TD>1</TD><TD>0</TD><TD>0</TD><TD>-1</TD>
|
|
* </TR>
|
|
* <TR>
|
|
* <TD>YR</TD>
|
|
* <TD>
|
|
* \image html yr.gif
|
|
* </TD>
|
|
* <TD>7</TD><TD>Vertical symetry followed by a 90° rotation</TD>
|
|
* <TD>0</TD><TD>1</TD><TD>1</TD><TD>0</TD>
|
|
* </TR>
|
|
* </TABLE>
|
|
*
|
|
* The transformation formula is given by : x' = (a * x) + (b *
|
|
* y) + tx y' = (c * x) + (d * y) + ty where x and y are the
|
|
* coordinates of any point, x' and y' the coordinates of the
|
|
* transformed point, tx and ty the horizontal and vertical
|
|
* components of the translation and where a, b, c and d are the
|
|
* coefficients of the matrix associated to the orientation.
|
|
*
|
|
*/
|
|
|
|
/*! \name Constructors
|
|
*/
|
|
// \{
|
|
|
|
/*! \function Transformation::Transformation();
|
|
* Default constructor : The translation is null and the
|
|
* orientation is equal to <b>ID</b>.
|
|
*/
|
|
|
|
/*! \function Transformation::Transformation(const Point& translation, const Transformation::Orientation& orientation=Orientation::ID);
|
|
* Builds a transformation whose translation part is defined by
|
|
* the argument \c \<translation\> and whose default orientation is
|
|
* <b>ID</b>.
|
|
*/
|
|
|
|
/*! \function Transformation::Transformation(const DbU::Unit& tx, const DbU::Unit& ty, const Transformation::Orientation& orientation=Orientation::ID);
|
|
* Builds a transformation whose translation part is defined by
|
|
* the arguments \c \<xt\> and \c \<ty\> and whose orientation
|
|
* is defined by \c \<orientation\> (\c \<ID\> by default).
|
|
*/
|
|
|
|
/*! \function Transformation::Transformation(const Point& translation, const Transformation::Orientation& orientation);
|
|
* Builds a transformation whose translation part is defined by
|
|
* the argument \c \<translation\> and whose orientation is
|
|
* defined by \c \<orientation\>.
|
|
*/
|
|
|
|
/*! \function Transformation::Transformation(const Transformation& transformation);
|
|
* Copy constructor.
|
|
*/
|
|
|
|
// \}
|
|
|
|
|
|
/*! \name Operators
|
|
*/
|
|
// \{
|
|
|
|
/*! \function Transformation& Transformation::operator=(const Transformation& transformation);
|
|
* Assignment operator.
|
|
*/
|
|
|
|
/*! \function bool Transformation::operator==(const Transformation& transformation) const;
|
|
* Two transformations are identical if their translations and
|
|
* orientation are identical.
|
|
*/
|
|
|
|
/*! \function bool Transformation::operator!=(const Transformation& transformation) const;
|
|
* Two transformations are different if eitheir their
|
|
* translations or orientation differ.
|
|
*/
|
|
|
|
// \}
|
|
|
|
|
|
/*! \name Accessors
|
|
*/
|
|
// \{
|
|
|
|
/*! \function const DbU::Unit& Transformation::getTx() const;
|
|
* \Return the horizontal component of the translation.
|
|
*/
|
|
|
|
/*! \function const DbU::Unit& Transformation::getTy() const;
|
|
* \Return the vertical component of the translation.
|
|
*/
|
|
|
|
/*! \function Point Transformation::getTranslation() const;
|
|
* \Return the translation component of the transformation.
|
|
*/
|
|
|
|
/*! \function const Translation::Orientation& Transformation::getOrientation() const;
|
|
* \Return the orientation of the transformation (may be used in a
|
|
* switch).
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getX(const DbU::Unit& x, const DbU::Unit& y) const;
|
|
* \Return the point abscissa resulting of the transformation
|
|
* application on the point defined by \c \<x\> et \c \<y\>.
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getY(const DbU::Unit& x, const DbU::Unit& y) const;
|
|
* \Return the point ordinate resulting of the transformation
|
|
* application on the point defined by \c \<x\> et \c \<y\>.
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getX(const Point& point) const;
|
|
* \Return the point abscissa resulting of the transformation
|
|
* application on \c \<point\>.
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getY(const Point& point) const;
|
|
* \Return the point ordinate resulting of the transformation
|
|
* application on \c \<point\>.
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getDx(const DbU::Unit& dx, const DbU::Unit& dy) const;
|
|
* \Return the horizontal component of the vector resulting from the
|
|
* application of the transformation on the vector defined by
|
|
* \c \<dx\> et \c \<dy\>.
|
|
*/
|
|
|
|
/*! \function DbU::Unit Transformation::getDy(const DbU::Unit& dx, const DbU::Unit& dy) const;
|
|
* \Return the vertical component of the vector resulting from the
|
|
* application of the transformation on the vector defined by
|
|
* \c \<dx\> et \c \<dy\>.
|
|
*/
|
|
|
|
/*! \function Point Transformation::getPoint(const DbU::Unit& x, const DbU::Unit& y) const;
|
|
* \Return the point resulting from the application of the
|
|
* transformation on the point defined by \c \<dx\> et
|
|
* \c \<dy\>.
|
|
*/
|
|
|
|
/*! \function Point Transformation::getPoint(const Point& point) const;
|
|
* \Return the point resulting from the application of the
|
|
* transformation on \c \<point\>.
|
|
*/
|
|
|
|
/*! \function Box Transformation::getBox(const DbU::Unit& x1, const DbU::Unit& y1, const DbU::Unit& x2, const DbU::Unit& y2) const;
|
|
* \Return the box resulting from the application of the transformation
|
|
* on the box defined by \c \<x1\>, \c \<y1\>, \c \<x2\> et
|
|
* \c \<y2\>.
|
|
*/
|
|
|
|
/*! \function Box Transformation::getBox(const Point& point1, const Point& point2) const;
|
|
* \Return the box resulting from the application of the transformation
|
|
* on the box defined by \c \<point1\> et \c \<point2\>.
|
|
*/
|
|
|
|
/*! \function Box Transformation::getBox(const Box& box) const;
|
|
* \Return the box resulting from the application of the transformation
|
|
* on the box \c \<box\>.
|
|
*/
|
|
|
|
/*! \function Transformation Transformation::getTransformation(const Transformation& transformation) const;
|
|
* \Return the transformation resulting from the application of the
|
|
* transformation on the transformation \c \<transformation\>.
|
|
*/
|
|
|
|
/*! \function Transformation Transformation::getInvert() const;
|
|
* \Return the inverse transformation.
|
|
*/
|
|
|
|
// \}
|
|
|
|
|
|
/*! \name Modifiers
|
|
*/
|
|
// \{
|
|
|
|
/*! \function Transformation& Transformation::invert();
|
|
* inverts the transformation \c \<this\> and returns a
|
|
* reference to it in order to apply in sequence a new function.
|
|
*/
|
|
|
|
// \}
|
|
|
|
|
|
/*! \section secTransformationTransformers Transformers
|
|
*
|
|
*
|
|
* <b>Transformation::applyOn</b>
|
|
*
|
|
* <b>Transformation::applyOn</b>
|
|
*
|
|
* <b>Transformation::applyOn</b>
|
|
*
|
|
* <b>Transformation::applyOn</b>
|
|
*/
|
|
|
|
|
|
|
|
/* \name Others
|
|
*/
|
|
// \{
|
|
|
|
/*! \function void Transformation::applyOn(DbU::Unit& x, DbU::Unit& y) const;
|
|
* Applies the transformation on the coordinates given in
|
|
* arguments.
|
|
*/
|
|
|
|
/*! \function void Transformation::applyOn(Point& point) const;
|
|
* Applies the transformation on the point given in argument.
|
|
*/
|
|
|
|
/*! \function void Transformation::applyOn(Box& box) const;
|
|
* Applies the transformation on the box given in argument.
|
|
*/
|
|
|
|
/*! \function void Transformation::applyOn(Transformation& transformation) const;
|
|
* Applies the transformation on the transformation given in
|
|
* argument. This last one becomes then the transformation
|
|
* resulting of the product of those two.
|
|
*/
|
|
|
|
// \}
|
|
|
|
}
|