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

📄 geometry.h

📁 浙江大学的悟空嵌入式系统模拟器
💻 H
📖 第 1 页 / 共 3 页
字号:
    return wxPoint2DInt( (int) (pt.m_x * n) , (int) (pt.m_y * n) );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2)
{
    return wxPoint2DInt( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n)
{
    return wxPoint2DInt( pt.m_x / n , pt.m_y / n );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n)
{
    return wxPoint2DInt( (int) (pt.m_x / n) , (int) (pt.m_y / n) );
}

// wxPoint2Ds represent a point or a vector in a 2d coordinate system

class WXDLLEXPORT wxPoint2DDouble
{
public :
    inline wxPoint2DDouble();
    inline wxPoint2DDouble( wxDouble x , wxDouble y );
    inline wxPoint2DDouble( const wxPoint2DDouble &pt );
    wxPoint2DDouble( const wxPoint2DInt &pt )
		{ 	m_x = (wxDouble) pt.m_x ; m_y = (wxDouble) pt.m_y ; }
	wxPoint2DDouble( const wxPoint &pt )
		{ 	m_x = (wxDouble) pt.x ; m_y = (wxDouble) pt.y ; }

    // two different conversions to integers, floor and rounding
    inline void GetFloor( wxInt32 *x , wxInt32 *y ) const;
    inline void GetRounded( wxInt32 *x , wxInt32 *y ) const;

    inline wxDouble GetVectorLength() const;
     wxDouble GetVectorAngle() const ;
    void SetVectorLength( wxDouble length );
    void SetVectorAngle( wxDouble degrees );
    void SetPolarCoordinates( wxDouble angle , wxDouble length );
    // set the vector length to 1.0, preserving the angle
    void Normalize();

    inline wxDouble GetDistance( const wxPoint2DDouble &pt ) const;
    inline wxDouble GetDistanceSquare( const wxPoint2DDouble &pt ) const;
    inline wxDouble GetDotProduct( const wxPoint2DDouble &vec ) const;
    inline wxDouble GetCrossProduct( const wxPoint2DDouble &vec ) const;

    // the reflection of this point
    inline wxPoint2DDouble operator-();

    inline wxPoint2DDouble& operator=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator+=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator-=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator*=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator*=(wxDouble n);
    inline wxPoint2DDouble& operator*=(wxInt32 n);
    inline wxPoint2DDouble& operator/=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator/=(wxDouble n);
    inline wxPoint2DDouble& operator/=(wxInt32 n);

    inline bool operator==(const wxPoint2DDouble& pt) const;
    inline bool operator!=(const wxPoint2DDouble& pt) const;

    wxDouble m_x;
    wxDouble m_y;
};

inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt);
inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n);

inline wxPoint2DDouble::wxPoint2DDouble()
{
    m_x = 0.0;
    m_y = 0.0;
}

inline wxPoint2DDouble::wxPoint2DDouble( wxDouble x , wxDouble y )
{
    m_x = x;
    m_y = y;
}

inline wxPoint2DDouble::wxPoint2DDouble( const wxPoint2DDouble &pt )
{
    m_x = pt.m_x;
    m_y = pt.m_y;
}

inline void wxPoint2DDouble::GetFloor( wxInt32 *x , wxInt32 *y ) const
{
    *x = (wxInt32) floor( m_x );
    *y = (wxInt32) floor( m_y );
}

inline void wxPoint2DDouble::GetRounded( wxInt32 *x , wxInt32 *y ) const
{
    *x = (wxInt32) floor( m_x + 0.5 );
    *y = (wxInt32) floor( m_y + 0.5);
}

inline wxDouble wxPoint2DDouble::GetVectorLength() const
{
    return sqrt( (m_x)*(m_x) + (m_y)*(m_y) ) ;
}

inline void wxPoint2DDouble::SetVectorLength( wxDouble length )
{
    wxDouble before = GetVectorLength() ;
    m_x = (m_x * length / before) ;
    m_y = (m_y * length / before) ;
}

inline wxDouble wxPoint2DDouble::GetDistance( const wxPoint2DDouble &pt ) const
{
    return sqrt( GetDistanceSquare( pt ) );
}

inline wxDouble wxPoint2DDouble::GetDistanceSquare( const wxPoint2DDouble &pt ) const
{
    return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) );
}

inline wxDouble wxPoint2DDouble::GetDotProduct( const wxPoint2DDouble &vec ) const
{
    return ( m_x * vec.m_x + m_y * vec.m_y );
}

inline wxDouble wxPoint2DDouble::GetCrossProduct( const wxPoint2DDouble &vec ) const
{
    return ( m_x * vec.m_y - vec.m_x * m_y );
}

inline wxPoint2DDouble wxPoint2DDouble::operator-()
{
    return wxPoint2DDouble( -m_x, -m_y);
}

inline wxPoint2DDouble& wxPoint2DDouble::operator=(const wxPoint2DDouble& pt)
{
    m_x = pt.m_x;
    m_y = pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator+=(const wxPoint2DDouble& pt)
{
    m_x = m_x + pt.m_x;
    m_y = m_y + pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator-=(const wxPoint2DDouble& pt)
{
    m_x = m_x - pt.m_x;
    m_y = m_y - pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator*=(const wxPoint2DDouble& pt)
{
    m_x = m_x * pt.m_x;
    m_y = m_y * pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt)
{
    m_x = m_x / pt.m_x;
    m_y = m_y / pt.m_y;
    return *this;
}

inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const
{
    return m_x == pt.m_x && m_y == pt.m_y;
}

inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const
{
    return m_x != pt.m_x || m_y != pt.m_y;
}

inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y );
}

inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y );
}


inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y );
}

inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n)
{
    return wxPoint2DDouble( pt.m_x / n , pt.m_y / n );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n)
{
    return wxPoint2DDouble( pt.m_x / n , pt.m_y / n );
}

// wxRect2Ds are a axis-aligned rectangles, each side of the rect is parallel to the x- or m_y- axis. The rectangle is either defined by the
// top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if
// left <= x < right  and top <= m_y < bottom , thus it is a half open interval.

class WXDLLEXPORT wxRect2DDouble
{
public:
    wxRect2DDouble()
        { m_x = m_y = m_width = m_height = 0; }
    wxRect2DDouble(wxDouble x, wxDouble y, wxDouble w, wxDouble h)
        { m_x = x; m_y = y; m_width = w;  m_height = h; }
/*
    wxRect2DDouble(const wxPoint2DDouble& topLeft, const wxPoint2DDouble& bottomRight);
    wxRect2DDouble(const wxPoint2DDouble& pos, const wxSize& size);
    wxRect2DDouble(const wxRect2DDouble& rect);
*/
        // single attribute accessors

    inline wxPoint2DDouble GetPosition()
        { return wxPoint2DDouble(m_x, m_y); }
    inline wxSize GetSize()
        { return wxSize((int) m_width, (int) m_height); }

    // for the edge and corner accessors there are two setters conterparts, the Set.. functions keep the other corners at their
        // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners apropriately

    inline wxDouble GetLeft() const { return m_x; }
    inline void SetLeft( wxDouble n ) { m_width += m_x - n; m_x = n; }
    inline void MoveLeftTo( wxDouble n ) { m_x = n; }
    inline wxDouble GetTop() const { return m_y; }
    inline void SetTop( wxDouble n ) { m_height += m_y - n; m_y = n; }
    inline void MoveTopTo( wxDouble n ) { m_y = n; }

⌨️ 快捷键说明

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