⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geometry.h

📁 This is an usefull library for Geometry in Mathmatics
💻 H
📖 第 1 页 / 共 2 页
字号:
/*! This class contains several static methods dealing with geometry.*/class Geometry{public:  // geometric series  static double getLengthGeomSeries(double dFirst,double dRatio,double dSum  );  static double getSumGeomSeries   (double dFirst,double dRatio,double dLen  );  static double getSumInfGeomSeries(double dFirst,double dRatio              );  static double getFirstGeomSeries (double dSum,  double dRatio,double dLen  );  static double getFirstInfGeomSeries(double dSum,double dRatio              );  // abc formula  static int    abcFormula(double a,double b, double c, double *s1,double *s2);};/*****************************************************************************//********************** CLASS CIRCLE *****************************************//*****************************************************************************//*!This class represents a circle. A circle is defined by one VecPosition   (which denotes the center) and its radius. */class Circle{    VecPosition m_posCenter;            /*!< Center of the circle  */    double      m_dRadius;              /*!< Radius of the circle  */public:    Circle( );    Circle( VecPosition pos, double dR );    void        show                  ( ostream& os = cout                   );    // get and set methods    bool        setCircle             ( VecPosition pos,                                        double      dR                       );    bool        setRadius             ( double dR                            );    double      getRadius             (                                      ) const;    bool        setCenter             ( VecPosition pos                      );    VecPosition getCenter             (                                      );    double      getCircumference      (                                      );    double      getArea               (                                      );    double      getVolume             (                                      ) const;    // calculate intersection points and area with other circle    bool        isInside              ( VecPosition pos, bool bCircle        );    int         getCircleIntersectionPoints ( Circle      c,                                        VecPosition *p1,                                        VecPosition *p2                      );    double      getIntersectionArea   ( Circle c, bool bStrict = false       );}  ;/*****************************************************************************//********************** CLASS SPHERE *****************************************//*****************************************************************************//*!This class represents a sphere. A sphere is defined by one VecPosition    (which denotes the center) and its radius*/typedef Circle Sphere;/*****************************************************************************//*********************** CLASS LINE ******************************************//*****************************************************************************//*!This class contains the representation of a line. A line is defined   by the formula ay + bx + c = 0. The coefficients a, b and c are stored   and used in the calculations. */class Line{  // a line is defined by the formula: ay + bx + c = 0  double m_a; /*!< This is the a coefficient in the line ay + bx + c = 0 */  double m_b; /*!< This is the b coefficient in the line ay + bx + c = 0 */  double m_c; /*!< This is the c coefficient in the line ay + bx + c = 0 */public:  Line( double a, double b, double c );  // print methods  void        show( ostream& os = cout );  friend      ostream& operator << (ostream & os, Line l);  // get intersection points with this line  VecPosition getIntersection            ( Line      line                  );  int         getCircleIntersectionPoints( Circle      circle,                                           VecPosition *posSolution1,                                           VecPosition *posSolution2         );  Line        getTangentLine             ( VecPosition pos                   );  VecPosition getPointOnLineClosestTo    ( VecPosition pos                   );  double      getDistanceWithPoint       ( VecPosition pos                   );  bool        isInBetween                ( VecPosition pos,                                           VecPosition point1,                                           VecPosition point2                );  // calculate associated variables in the line  double      getYGivenX                 ( double      x );  double      getXGivenY                 ( double      y );  double      getACoefficient            (               ) const;  double      getBCoefficient            (               ) const;  double      getCCoefficient            (               ) const;  // static methods to make a line using an easier representation.  static Line makeLineFromTwoPoints      ( VecPosition pos1,                                           VecPosition pos2                  );  static Line makeLineFromPositionAndAngle( VecPosition vec,                                           AngDeg angle                      );};/******************************************************************************//**************************** CLASS RECTANGLE *********************************//******************************************************************************//*!This class represents a rectangle. A rectangle is defined by two   VecPositions the one at the upper left corner and the one at the   right bottom. */class Rect{  VecPosition m_posLeftTop;     /*!< top left position of the rectangle      */  VecPosition m_posRightBottom; /*!< bottom right position of the rectangle  */public:  Rect                          ( VecPosition pos, VecPosition pos2 );  void        show              ( ostream& os = cout                );  // checks whether point lies inside the rectangle  bool        isInside          ( VecPosition pos                   );  // standard get and set methods  void        setRectanglePoints( VecPosition pos1,                                  VecPosition pos2                  );  bool        setPosLeftTop     ( VecPosition pos                   );  VecPosition getPosLeftTop     (                                   );  bool        setPosRightBottom ( VecPosition pos                   );  VecPosition getPosRightBottom (                                   );};/******************************************************************************//*************************** CLASS PLANE **************************************//******************************************************************************//*!This class represents a plane in 3 Dimensional space. A plane is   defined by a normal vector and a point in the plane.*/class Plane{  double m_Delta;  VecPosition m_Normal;public:  Plane                         ( VecPosition norm                                           = VecPosition( 0, 0, 0 ),                                  VecPosition pos                                          = VecPosition( 0, 0, 0 )  );  void        show              ( ostream& os = cout                ) const;  // checks whether point lies inside the rectangle  bool        isInside          ( VecPosition pos                   ) const;  // standard get and set methods  void        setPlane          ( VecPosition newNormal,                                  VecPosition newPoint              );  bool        setPlaneNormal    ( VecPosition newNormal             );  VecPosition getPlaneNormal    (                                   ) const;  bool        setPlaneDelta     ( double newDelta                   );  double      getPlaneDelta     (                                   ) const;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -