]> Creatis software - clitk.git/blobdiff - utilities/CxImage/ximath.cpp
cosmetic
[clitk.git] / utilities / CxImage / ximath.cpp
index 017518445dbf7aed601fd444299eaf769a9f5440..37533e2280c0e6c0f4227d4a9ee467e0179b6ee2 100644 (file)
@@ -1,97 +1,97 @@
-#include "ximage.h"\r
-#include "ximath.h"\r
-#include <math.h>\r
-\r
-//this module should contain some classes for geometrical transformations\r
-//usable with selections, etc... once it's done, that is. :)\r
-\r
-CxPoint2::CxPoint2()\r
-{\r
-  x=y=0.0f;\r
-}\r
-\r
-CxPoint2::CxPoint2(float const x_, float const y_)\r
-{\r
-  x=x_;\r
-  y=y_;\r
-}\r
-\r
-CxPoint2::CxPoint2(CxPoint2 const &p)\r
-{\r
-  x=p.x;\r
-  y=p.y;\r
-}\r
-\r
-float CxPoint2::Distance(CxPoint2 const p2)\r
-{\r
-  return (float)sqrt((x-p2.x)*(x-p2.x)+(y-p2.y)*(y-p2.y));\r
-}\r
-\r
-float CxPoint2::Distance(float const x_, float const y_)\r
-{\r
-  return (float)sqrt((x-x_)*(x-x_)+(y-y_)*(y-y_));\r
-}\r
-\r
-CxRect2::CxRect2()\r
-{\r
-}\r
-\r
-CxRect2::CxRect2(float const x1_, float const y1_, float const x2_, float const y2_)\r
-{\r
-  botLeft.x=x1_;\r
-  botLeft.y=y1_;\r
-  topRight.x=x2_;\r
-  topRight.y=y2_;\r
-}\r
-\r
-CxRect2::CxRect2(CxRect2 const &p)\r
-{\r
-  botLeft=p.botLeft;\r
-  topRight=p.topRight;\r
-}\r
-\r
-float CxRect2::Surface() const\r
-/*\r
- * Returns the surface of rectangle.\r
- */\r
-{\r
-  return (topRight.x-botLeft.x)*(topRight.y-botLeft.y);\r
-}\r
-\r
-CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const\r
-/*\r
- * Returns crossection with another rectangle.\r
- */\r
-{\r
-  CxRect2 cs;\r
-  cs.botLeft.x=max(botLeft.x, r2.botLeft.x);\r
-  cs.botLeft.y=max(botLeft.y, r2.botLeft.y);\r
-  cs.topRight.x=min(topRight.x, r2.topRight.x);\r
-  cs.topRight.y=min(topRight.y, r2.topRight.y);\r
-  if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {\r
-    return cs;\r
-  } else {\r
-    return CxRect2(0,0,0,0);\r
-  }//if\r
-}\r
-\r
-CxPoint2 CxRect2::Center() const\r
-/*\r
- * Returns the center point of rectangle.\r
- */\r
-{\r
-  return CxPoint2((topRight.x+botLeft.x)/2.0f, (topRight.y+botLeft.y)/2.0f);\r
-}\r
-\r
-float CxRect2::Width() const\r
-//returns rectangle width\r
-{\r
-  return topRight.x-botLeft.x;\r
-}\r
-\r
-float CxRect2::Height() const\r
-//returns rectangle height\r
-{\r
-  return topRight.y-botLeft.y;\r
-}\r
-\r
+#include "ximage.h"
+#include "ximath.h"
+#include <math.h>
+
+//this module should contain some classes for geometrical transformations
+//usable with selections, etc... once it's done, that is. :)
+
+CxPoint2::CxPoint2()
+{
+  x=y=0.0f;
+}
+
+CxPoint2::CxPoint2(float const x_, float const y_)
+{
+  x=x_;
+  y=y_;
+}
+
+CxPoint2::CxPoint2(CxPoint2 const &p)
+{
+  x=p.x;
+  y=p.y;
+}
+
+float CxPoint2::Distance(CxPoint2 const p2)
+{
+  return (float)sqrt((x-p2.x)*(x-p2.x)+(y-p2.y)*(y-p2.y));
+}
+
+float CxPoint2::Distance(float const x_, float const y_)
+{
+  return (float)sqrt((x-x_)*(x-x_)+(y-y_)*(y-y_));
+}
+
+CxRect2::CxRect2()
+{
+}
+
+CxRect2::CxRect2(float const x1_, float const y1_, float const x2_, float const y2_)
+{
+  botLeft.x=x1_;
+  botLeft.y=y1_;
+  topRight.x=x2_;
+  topRight.y=y2_;
+}
+
+CxRect2::CxRect2(CxRect2 const &p)
+{
+  botLeft=p.botLeft;
+  topRight=p.topRight;
+}
+
+float CxRect2::Surface() const
+/*
+ * Returns the surface of rectangle.
+ */
+{
+  return (topRight.x-botLeft.x)*(topRight.y-botLeft.y);
+}
+
+CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
+/*
+ * Returns crossection with another rectangle.
+ */
+{
+  CxRect2 cs;
+  cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
+  cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
+  cs.topRight.x=min(topRight.x, r2.topRight.x);
+  cs.topRight.y=min(topRight.y, r2.topRight.y);
+  if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
+    return cs;
+  } else {
+    return CxRect2(0,0,0,0);
+  }//if
+}
+
+CxPoint2 CxRect2::Center() const
+/*
+ * Returns the center point of rectangle.
+ */
+{
+  return CxPoint2((topRight.x+botLeft.x)/2.0f, (topRight.y+botLeft.y)/2.0f);
+}
+
+float CxRect2::Width() const
+//returns rectangle width
+{
+  return topRight.x-botLeft.x;
+}
+
+float CxRect2::Height() const
+//returns rectangle height
+{
+  return topRight.y-botLeft.y;
+}
+