Committed C# port from Mohamad
[zxing.git] / csharp / qrcode / detector / AlignmentPattern.cs
diff --git a/csharp/qrcode/detector/AlignmentPattern.cs b/csharp/qrcode/detector/AlignmentPattern.cs
new file mode 100755 (executable)
index 0000000..562a1d2
--- /dev/null
@@ -0,0 +1,56 @@
+/*\r
+* Copyright 2007 ZXing authors\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+*      http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+using System;\r
+using com.google.zxing;\r
+using com.google.zxing.common;\r
+\r
+namespace com.google.zxing.qrcode.detector\r
+{\r
+    public sealed class AlignmentPattern : ResultPoint\r
+    {\r
+          private  float posX;\r
+          private  float posY;\r
+          private  float estimatedModuleSize;\r
+\r
+          public AlignmentPattern(float posX, float posY, float estimatedModuleSize) {\r
+            this.posX = posX;\r
+            this.posY = posY;\r
+            this.estimatedModuleSize = estimatedModuleSize;\r
+          }\r
+\r
+          public float getX() {\r
+            return posX;\r
+          }\r
+\r
+          public float getY() {\r
+            return posY;\r
+          }\r
+\r
+          /**\r
+           * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated\r
+           * position and size -- meaning, it is at nearly the same center with nearly the same size.</p>\r
+           */\r
+          public bool aboutEquals(float moduleSize, float i, float j) {\r
+            return\r
+                Math.Abs(i - posY) <= moduleSize &&\r
+                    Math.Abs(j - posX) <= moduleSize &&\r
+                    (Math.Abs(moduleSize - estimatedModuleSize) <= 1.0f ||\r
+                        Math.Abs(moduleSize - estimatedModuleSize) / estimatedModuleSize <= 0.1f);\r
+          }\r
+    }\r
+    \r
+\r
+}
\ No newline at end of file