Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Modules/WalkingEngine/GT2005Polygon.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002 * @file GT2005Polygon.h
    00003 * Definition of class GT2005Polygon
    00004 * @author Denis Fisseler
    00005 ****************************************************************************/
    00006
    00007 #ifndef GT2005Polygon_h
    00008 #define GT2005Polygon_h
    00009
    00010 #include "Tools/Math/Vector3.h"
    00011 #include <string.h>
    00012 #include <math.h>
    00013
    00014 /***************************************************************************
    00015 * @class GT2005Polygon
    00016 *
    00017 * Polygon class for the GT2005 Walking Engine
    00018 * @author Denis Fisseler
    00019 ***************************************************************************/
    00020 class GT2005Polygon
    00021 {
    00022 public:
    00023   // Constructor
    00024   GT2005Polygon(int nPoints = 0, int sLength = 0);
    00025
    00026   // Destructor
    00027   ~GT2005Polygon();
    00028
    00029   int stepLength; // time for one cycle in ticks
    00030
    00031 //  <Finger weg sonst Finger ab!>
    00032   enum {maxPoints = 128};
    00033   typedef struct
    00034   {
    00035     Vector3<double> point; // coordinates of the point
    00036     double sLen; // run-through-time for the edge relative to the time for the whole polygon
    00037   } pSegment;
    00038   pSegment pPoints[maxPoints];
    00039 //  </Finger weg sonst Finger ab!>
    00040
    00041   int numPoints; // the number of points in use for this polygon
    00042
    00043   // (only valid after calling finalize)
    00044   double polyLengthX; // x-length  of the polygon
    00045   double groundTime; // relative to stepLenght, approximated ground time for the polygon
    00046   Vector3<double> centerOfMassCorrection;
    00047
    00048   double rollAngle; // roll angle (x-axis)
    00049
    00050   Vector3<double> getPointCoord(int pNum); // pNum: [0 ... numPoints-1]
    00051   void setPointCoord(int pNum, Vector3<double> p); // pNum: [0 ... numPoints-1]
    00052
    00053   void getSegment(int sNum, double &sLen, Vector3<double> &p); // sNum: [0 ... numPoints-1]
    00054   void setSegment(int sNum, double sLen, Vector3<double> p); // sNum: [0 ... numPoints-1]
    00055   double getSegmentLength(int sNum); // sNum: [0 ... numPoints-1]
    00056
    00057   Vector3<double> getPositionOnShape(double pos); // pos: [0 ... 1]
    00058
    00059   void insertPoint(int pNum); // pNum: point will be inserted between pNum and pNum+1
    00060
    00061   GT2005Polygon* interpolateShape(double amount, GT2005Polygon* s2); // amount: [0 ... 1]
    00062   void interpolateShapeP(double amount, GT2005Polygon* s2); // amount: [0 ... 1]    put the result in this poly
    00063
    00064   int getMaxX();
    00065   int getMinX();
    00066   double approxGroundTime();
    00067   Vector3<double> calculateCenterOfMass();
    00068   void finalize();
    00069
    00070   GT2005Polygon scaleX(double s); // return a polygon X-scaled around the zero position
    00071   GT2005Polygon scaleY(double s); // return a polygon Y-scaled around the zero position
    00072
    00073   GT2005Polygon rotateX(double a); // return a polygon X-rotated around the zero position
    00074   GT2005Polygon rotateY(double a); // return a polygon Y-rotated around the zero position
    00075   GT2005Polygon rotateZ(double a); // return a polygon Z-rotated around the zero position
    00076
    00077   void rotateXP(double a); // modify polygon (X-rotate around the zero position)
    00078   void rotateYP(double a); // modify polygon (Y-rotate around the zero position)
    00079   void rotateZP(double a); // modify polygon (Z-rotate around the zero position)
    00080
    00081   GT2005Polygon rotateZC(double a);  // return a polygon Z-rotated around the center of mass
    00082
    00083   bool load(char* filename); // save polygon to a file
    00084   void save(char* filename); // load polygon from a file
    00085
    00086   GT2005Polygon* copy(); // return a copy of the polygon
    00087   GT2005Polygon* mirrorY(); // return an Y-mirrored copy of the polygon
    00088 };
    00089
    00090 // streaming operators
    00091 In& operator>>(In& stream, GT2005Polygon& Polygon);
    00092 Out& operator<<(Out& stream, const GT2005Polygon& Polygon);
    00093
    00094 #endif // GT2005Polygon_h