home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / GRAPH / CURVE.H < prev    next >
Text File  |  1995-03-15  |  3KB  |  104 lines

  1. /*************************************************************************
  2.   IBM C/C++ Tools Version 3.00 - Collection Class Library
  3.  (C) Copyright IBM Corporation 1992 ,1995, Licensed Program-Property of
  4.  IBM.  All Rights Reserved.  US Government Users Restricted Rights - Use,
  5.  duplication or disclosure restricted by GSA ADP Schedule Contract with
  6.  IBM Corp.
  7.  *************************************************************************/
  8.  
  9. #if defined (_SUN)
  10. #include <istring.h>
  11. #else
  12. #include <istring.hpp>
  13. #endif
  14.  
  15.  
  16. class Curve : public Graphics
  17. {
  18. public:
  19.  
  20.   float ivXStart;
  21.   float ivYStart;
  22.   float ivXFix1;
  23.   float ivYFix1;
  24.   float ivXFix2;
  25.   float ivYFix2;
  26.   float ivXFix3;
  27.   float ivYFix3;
  28.   float ivXEnd;
  29.   float ivYEnd;
  30.  
  31.  
  32.   Curve(int graphicsKey, IString id,
  33.         float xstart, float ystart,
  34.         float xfix1, float yfix1,
  35.         float xfix2, float yfix2,
  36.         float xfix3, float yfix3,
  37.         float xend, float yend)
  38.                                   :  Graphics(graphicsKey, id),
  39.                                      ivXStart(xstart),
  40.                                      ivYStart(ystart),
  41.                                      ivXFix1(xfix1),
  42.                                      ivYFix1(yfix1),
  43.                                      ivXFix2(xfix2),
  44.                                      ivYFix2(yfix2),
  45.                                      ivXFix3(xfix3),
  46.                                      ivYFix3(yfix3),
  47.                                      ivXEnd(xend),
  48.                                      ivYEnd(yend)
  49.                                      { }
  50.  
  51.  
  52.  
  53.   IBoolean operator== (Curve const& curve) const
  54.     {
  55.      return (this->ivXStart == curve.ivXStart &&
  56.              this->ivYStart == curve.ivYStart &&
  57.              this->ivXFix1  == curve.ivXFix1  &&
  58.              this->ivYFix1  == curve.ivYFix1  &&
  59.              this->ivXFix2  == curve.ivXFix2  &&
  60.              this->ivYFix2  == curve.ivYFix2  &&
  61.              this->ivXFix3  == curve.ivXFix3  &&
  62.              this->ivYFix3  == curve.ivYFix3  &&
  63.              this->ivXEnd   == curve.ivXEnd   &&
  64.              this->ivYEnd   == curve.ivYEnd);
  65.     }
  66.  
  67.  
  68.   void           draw() const
  69.     {
  70.      cout << "drawing "
  71.           << Graphics::id()
  72.           << endl
  73.           << "with starting point: "
  74.           << "(" << this->ivXStart << "|"
  75.           << this->ivYStart << ")"
  76.           << endl
  77.           << "and with fix points: "
  78.           << "(" << this->ivXFix1 << "|" << this->ivYFix1 << ")"
  79.           << "(" << this->ivXFix2 << "|" << this->ivYFix2 << ")"
  80.           << "(" << this->ivXFix3 << "|" << this->ivYFix3 << ")"
  81.           << endl
  82.           << "and with ending point: "
  83.           << "(" << this->ivXEnd << "|" << this->ivYEnd << ")"
  84.           << endl;
  85.     }
  86.  
  87.  
  88.   void           lengthOfCurve() const
  89.     {
  90.      cout << "Length of "
  91.           << Graphics::id()
  92.           << " is: "
  93.           << (sqrt(pow(((this->ivXFix1) - (this->ivXStart)),2)
  94.                  + pow(((this->ivYFix1) - (this->ivYStart)),2))
  95.             + sqrt(pow(((this->ivXFix2) - (this->ivXFix1)),2)
  96.                  + pow(((this->ivYFix2) - (this->ivYFix1)),2))
  97.             + sqrt(pow(((this->ivXFix3) - (this->ivXFix2)),2)
  98.                  + pow(((this->ivYFix3) - (this->ivYFix2)),2))
  99.             + sqrt(pow(((this->ivXEnd) -  (this->ivXFix3)),2)
  100.                  + pow(((this->ivYEnd) - (this->ivYFix3)),2)))
  101.           << endl;
  102.     }
  103. };
  104.