Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaned up CxMath.cpp

  • Loading branch information...
commit 2c601e5c8779474b9fb99678f6a9d9d6e015da93 1 parent af2fc20
@grahamboree authored
Showing with 26 additions and 22 deletions.
  1. +26 −22 Source/cppimage/CxMath.cpp
View
48 Source/cppimage/CxMath.cpp
@@ -1,29 +1,33 @@
+//
+// CxMath.cpp
+// cppimage
+//
+// Created by Graham Pentheny on 11/10/12.
+// Copyright (c) 2012 Graham Pentheny. All rights reserved.
+//
#include "CxMath.h"
-#include "CxImage.h"
-#include <math.h>
-
-//this module should contain some classes for geometrical transformations
-//usable with selections, etc... once it's done, that is. :)
-
-//////////////////////////////////////////////////////////////////////////
-CxRect2 CxRect2::CrossSection(const CxRect2& inRect2) const
-/*
- * Returns crossection with another rectangle.
- */
+namespace CppImage
{
- CxRect2 cs;
- cs.botLeft.x = max(botLeft.x, inRect2.botLeft.x);
- cs.botLeft.y = max(botLeft.y, inRect2.botLeft.y);
- cs.topRight.x = min(topRight.x, inRect2.topRight.x);
- cs.topRight.y = min(topRight.y, inRect2.topRight.y);
- if (cs.botLeft.x <= cs.topRight.x && cs.botLeft.y <= cs.topRight.y)
- {
- return cs;
- }
- else
+ //////////////////////////////////////////////////////////////////////////
+ /// Returns the intersection crossection with another rectangle or a 0 area
+ /// rectangle if there is no overlap.
+ /// @param[in] inRect
+ CxRect2 CxRect2::CrossSection(const CxRect2& inRect) const
{
- return CxRect2(0,0,0,0);
+ CxRect2 crossSection;
+ crossSection.botLeft.x = max(botLeft.x, inRect.botLeft.x);
+ crossSection.botLeft.y = max(botLeft.y, inRect.botLeft.y);
+ crossSection.topRight.x = min(topRight.x, inRect.topRight.x);
+ crossSection.topRight.y = min(topRight.y, inRect.topRight.y);
+ if (cs.botLeft.x <= cs.topRight.x && cs.botLeft.y <= cs.topRight.y)
+ {
+ return crossSection;
+ }
+ else
+ {
+ return CxRect2(0,0,0,0);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.