5 //this module should contain some classes for geometrical transformations
\r
6 //usable with selections, etc... once it's done, that is. :)
\r
13 CxPoint2::CxPoint2(float const x_, float const y_)
\r
19 CxPoint2::CxPoint2(CxPoint2 const &p)
\r
25 float CxPoint2::Distance(CxPoint2 const p2)
\r
27 return (float)sqrt((x-p2.x)*(x-p2.x)+(y-p2.y)*(y-p2.y));
\r
30 float CxPoint2::Distance(float const x_, float const y_)
\r
32 return (float)sqrt((x-x_)*(x-x_)+(y-y_)*(y-y_));
\r
39 CxRect2::CxRect2(float const x1_, float const y1_, float const x2_, float const y2_)
\r
47 CxRect2::CxRect2(CxRect2 const &p)
\r
50 topRight=p.topRight;
\r
53 float CxRect2::Surface() const
\r
55 * Returns the surface of rectangle.
\r
58 return (topRight.x-botLeft.x)*(topRight.y-botLeft.y);
\r
61 CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
\r
63 * Returns crossection with another rectangle.
\r
67 cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
\r
68 cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
\r
69 cs.topRight.x=min(topRight.x, r2.topRight.x);
\r
70 cs.topRight.y=min(topRight.y, r2.topRight.y);
\r
71 if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
\r
74 return CxRect2(0,0,0,0);
\r
78 CxPoint2 CxRect2::Center() const
\r
80 * Returns the center point of rectangle.
\r
83 return CxPoint2((topRight.x+botLeft.x)/2.0f, (topRight.y+botLeft.y)/2.0f);
\r
86 float CxRect2::Width() const
\r
87 //returns rectangle width
\r
89 return topRight.x-botLeft.x;
\r
92 float CxRect2::Height() const
\r
93 //returns rectangle height
\r
95 return topRight.y-botLeft.y;
\r