You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2017/05/12 15:17:07 UTC

[2/2] commons-numbers git commit: NUMBERS-37: New "PlaneAngle" class.

NUMBERS-37: New "PlaneAngle" class.

New module for angle-related utilities.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/1aa1ddcd
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/1aa1ddcd
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/1aa1ddcd

Branch: refs/heads/master
Commit: 1aa1ddcd5a3bfdb99ae38bc5c761a80adb166ad6
Parents: 475b7f0
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Fri May 12 17:05:42 2017 +0200
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Fri May 12 17:05:42 2017 +0200

----------------------------------------------------------------------
 commons-numbers-angle/LICENSE.txt               | 201 +++++++++++++++++++
 commons-numbers-angle/NOTICE.txt                |   6 +
 commons-numbers-angle/README.md                 |  98 +++++++++
 commons-numbers-angle/pom.xml                   |  45 +++++
 .../commons/numbers/angle/PlaneAngle.java       | 133 ++++++++++++
 .../commons/numbers/angle/package-info.java     |  20 ++
 commons-numbers-angle/src/site/site.xml         |  35 ++++
 commons-numbers-angle/src/site/xdoc/index.xml   |  40 ++++
 .../commons/numbers/angle/PlaneAngleTest.java   | 136 +++++++++++++
 pom.xml                                         |   1 +
 10 files changed, 715 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/LICENSE.txt
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/LICENSE.txt b/commons-numbers-angle/LICENSE.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/commons-numbers-angle/LICENSE.txt
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/NOTICE.txt
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/NOTICE.txt b/commons-numbers-angle/NOTICE.txt
new file mode 100644
index 0000000..9091baa
--- /dev/null
+++ b/commons-numbers-angle/NOTICE.txt
@@ -0,0 +1,6 @@
+Apache Commons Numbers
+Copyright 2001-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/README.md
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/README.md b/commons-numbers-angle/README.md
new file mode 100644
index 0000000..abe365a
--- /dev/null
+++ b/commons-numbers-angle/README.md
@@ -0,0 +1,98 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!---
+ +======================================================================+
+ |****                                                              ****|
+ |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
+ |****                    DO NOT EDIT DIRECTLY                      ****|
+ |****                                                              ****|
+ +======================================================================+
+ | TEMPLATE FILE: readme-md-template.md                                 |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ |                                                                      |
+ | 1) Re-generate using: mvn commons:readme-md                          |
+ |                                                                      |
+ | 2) Set the following properties in the component's pom:              |
+ |    - commons.componentid (required, alphabetic, lower case)          |
+ |    - commons.release.version (required)                              |
+ |                                                                      |
+ | 3) Example Properties                                                |
+ |                                                                      |
+ |  <properties>                                                        |
+ |    <commons.componentid>math</commons.componentid>                   |
+ |    <commons.release.version>1.2</commons.release.version>            |
+ |  </properties>                                                       |
+ |                                                                      |
+ +======================================================================+
+--->
+Apache Commons Numbers Core
+===================
+
+Basic utilities.
+
+Documentation
+-------------
+
+More information can be found on the [homepage](https://commons.apache.org/proper/commons-numbers).
+The [JavaDoc](https://commons.apache.org/proper/commons-numbers/javadocs/api-release) can be browsed.
+Questions related to the usage of Apache Commons Numbers Core should be posted to the [user mailing list][ml].
+
+Where can I get the latest release?
+-----------------------------------
+You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-numbers/download_numbers.cgi).
+
+Alternatively you can pull it from the central Maven repositories:
+
+```xml
+<dependency>
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-numbers-angle</artifactId>
+  <version>1.0</version>
+</dependency>
+```
+
+Contributing
+------------
+
+We accept PRs via github. The [developer mailing list][ml] is the main channel of communication for contributors.
+There are some guidelines which will make applying PRs easier for us:
++ No tabs! Please use spaces for indentation.
++ Respect the code style.
++ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn clean test```.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
+You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md).
+
+License
+-------
+Code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0.txt).
+
+Donations
+---------
+You like Apache Commons Numbers Core? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
+
+Additional Resources
+--------------------
+
++ [Apache Commons Homepage](https://commons.apache.org/)
++ [Apache Bugtracker (JIRA)](https://issues.apache.org/jira/)
++ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
++ #apachecommons IRC channel on freenode.org
+
+[ml]:https://commons.apache.org/mail-lists.html

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/pom.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/pom.xml b/commons-numbers-angle/pom.xml
new file mode 100644
index 0000000..507713a
--- /dev/null
+++ b/commons-numbers-angle/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-numbers-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-numbers-angle</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Apache Commons Numbers Angle</name>
+
+  <description>Utilities related to the concept of angle.</description>
+
+  <properties>
+    <!-- This value must reflect the current name of the base package. -->
+    <commons.osgi.symbolicName>org.apache.commons.numbers.angle</commons.osgi.symbolicName>
+    <!-- OSGi -->
+    <commons.osgi.export>org.apache.commons.numbers.angle</commons.osgi.export>
+    <!-- Workaround to avoid duplicating config files. -->
+    <numbers.parent.dir>${basedir}/..</numbers.parent.dir>
+  </properties>
+
+</project>

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
new file mode 100644
index 0000000..1820b62
--- /dev/null
+++ b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/PlaneAngle.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.numbers.angle;
+
+/**
+ * Represents the <a href="https://en.wikipedia.org/wiki/Angle">angle</a> concept.
+ */
+public class PlaneAngle {
+    /** Conversion factor. */
+    private static final double HALF_TURN = 0.5;
+    /** Conversion factor. */
+    private static final double TO_RADIANS = 2 * Math.PI;
+    /** Conversion factor. */
+    private static final double FROM_RADIANS = 1d / TO_RADIANS;
+    /** Conversion factor. */
+    private static final double TO_DEGREES = 360;
+    /** Conversion factor. */
+    private static final double FROM_DEGREES = 1d / TO_DEGREES;
+    /** Zero. */
+    private static final PlaneAngle ZERO = new PlaneAngle(0);
+    /** Value (in turns). */
+    private final double value;
+
+    /**
+     * @param value Value in turns.
+     */
+    private PlaneAngle(double value) {
+        this.value = value;
+    }
+
+    /**
+     * @param angle (in <a href="https://en.wikipedia.org/wiki/Turn_%28geometry%29">turns</a>).
+     * @return a new intance.
+     */
+    public static PlaneAngle ofTurns(double angle) {
+        return new PlaneAngle(angle);
+    }
+    /**
+     * @param angle (in <a href="https://en.wikipedia.org/wiki/Radian">radians</a>).
+     * @return a new intance.
+     */
+    public static PlaneAngle ofRadians(double angle) {
+        return new PlaneAngle(angle * FROM_RADIANS);
+    }
+    /**
+     * @param angle (in <a href="https://en.wikipedia.org/wiki/Degree_%28angle%29">degrees</a>).
+     * @return a new intance.
+     */
+    public static PlaneAngle ofDegrees(double angle) {
+        return new PlaneAngle(angle * FROM_DEGREES);
+    }
+
+    /**
+     * @return the value in <a href="https://en.wikipedia.org/wiki/Turn_%28geometry%29">turns</a>.
+     */
+    public double toTurns() {
+        return value;
+    }
+    /**
+     * @return the value in <a href="https://en.wikipedia.org/wiki/Radian">radians</a>.
+     */
+    public double toRadians() {
+        return value * TO_RADIANS;
+    }
+    /**
+     * @return the value in <a href="https://en.wikipedia.org/wiki/Degree_%28angle%29">degrees</a>.
+     */
+    public double toDegrees() {
+        return value * TO_DEGREES;
+    }
+
+    /**
+     * Normalize an angle in an interval of size 1 turn around a
+     * center value.
+     *
+     * @param center Center of the desired interval for the result.
+     * @return {@code a - 2 * k} with integer {@code k} such that
+     * {@code center - 0.5 <= a - 2 * k <= center + 0.5} (in turns).
+     */
+    public PlaneAngle normalize(PlaneAngle center) {
+        return new PlaneAngle(value - Math.floor(value + HALF_TURN - center.value));
+    }
+
+    /**
+     * Normalize within the interval centered at 0.
+     *
+     * @return {@code a - 2 * k} with integer {@code k} such that
+     * {@code -0.5 <= a - 2 * k <= 0.5} (in turns).
+     */
+    public PlaneAngle normalize() {
+        return normalize(ZERO);
+    }
+
+    /**
+     * Test for equality with another object.
+     * Objects are considered to be equal if the two values are exactly the
+     * same, or both are {@code Double.NaN}.
+     *
+     * @param other Object to test for equality with this instance.
+     * @return {@code true} if the objects are equal, {@code false} if
+     * {@code other} is {@code null}, not an instance of {@code PlaneAngle},
+     * or not equal to this instance.
+     */
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other instanceof PlaneAngle){
+            return new Double(value).equals(new Double(((PlaneAngle) other).value));
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return new Double(value).hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/package-info.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/package-info.java b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/package-info.java
new file mode 100644
index 0000000..bc4aa49
--- /dev/null
+++ b/commons-numbers-angle/src/main/java/org/apache/commons/numbers/angle/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Angle-related utilities.
+ */
+package org.apache.commons.numbers.angle;

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/src/site/site.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/site/site.xml b/commons-numbers-angle/src/site/site.xml
new file mode 100644
index 0000000..512e72e
--- /dev/null
+++ b/commons-numbers-angle/src/site/site.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project name="Numbers">
+  <bannerRight>
+    <name>Apache Commons Numbers</name>
+    <src>/images/commons_numbers.small.png</src>
+    <href>/index.html</href>
+  </bannerRight>
+
+  <body>
+    <menu name="Numbers Angle">
+      <item name="Overview" href="index.html"/>
+      <item name="Latest API docs (development)"
+            href="apidocs/index.html"/>
+      <!--item name="Javadoc (1.0 release)"
+            href="http://commons.apache.org/rng/commons-numbers-angle/javadocs/api-1.0/index.html"/-->
+    </menu>
+
+  </body>
+</project>

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/site/xdoc/index.xml b/commons-numbers-angle/src/site/xdoc/index.xml
new file mode 100644
index 0000000..aa5f37d
--- /dev/null
+++ b/commons-numbers-angle/src/site/xdoc/index.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+  
+<document>
+
+  <properties>
+    <title>Commons Numbers Angle</title>
+  </properties>
+
+  <body>
+
+    <section name="Apache Commons Numbers: Number types" href="summary">
+      <p>
+        Commons Numbers provides utilities such as complex numbers and fractions.
+      </p>
+
+      <p>
+        The "angle" module contains utilities related to the concept of angle.
+      </p>
+    </section>
+
+  </body>
+
+</document>

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
new file mode 100644
index 0000000..61b72f7
--- /dev/null
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.commons.numbers.angle;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test cases for the {@link PlaneAngle} class.
+ */
+public class PlaneAngleTest {
+    @Test
+    public void testConversionTurns() {
+        final double value = 12.3456;
+        final PlaneAngle a = PlaneAngle.ofTurns(value);
+        Assert.assertEquals(value, a.toTurns(), Math.ulp(value));
+    }
+
+    @Test
+    public void testConversionRadians() {
+        final double value = 12.3456;
+        final PlaneAngle a = PlaneAngle.ofRadians(value);
+        Assert.assertEquals(value, a.toRadians(), Math.ulp(value));
+    }
+
+    @Test
+    public void testConversionDegrees() {
+        final double value = 12.3456;
+        final PlaneAngle a = PlaneAngle.ofDegrees(value);
+        Assert.assertEquals(value, a.toDegrees(), Math.ulp(value));
+    }
+
+    @Test
+    public void testNormalizeRadians() {
+        for (double a = -15.0; a <= 15.0; a += 0.1) {
+            for (double b = -15.0; b <= 15.0; b += 0.2) {
+                final PlaneAngle aA = PlaneAngle.ofRadians(a);
+                final PlaneAngle aB = PlaneAngle.ofRadians(b);
+                final double c = aA.normalize(aB).toRadians();
+                Assert.assertTrue((b - Math.PI) <= c);
+                Assert.assertTrue(c <= (b + Math.PI));
+                double twoK = Math.rint((a - c) / Math.PI);
+                Assert.assertEquals(c, a - twoK * Math.PI, 1e-14);
+            }
+        }
+    }
+
+    @Test
+    public void testNormalizeMixed() {
+        for (double a = -15.0; a <= 15.0; a += 0.1) {
+            for (double b = -15.0; b <= 15.0; b += 0.2) {
+                final PlaneAngle aA = PlaneAngle.ofDegrees(a);
+                final PlaneAngle aB = PlaneAngle.ofRadians(b);
+                final double c = aA.normalize(aB).toTurns();
+                Assert.assertTrue((aB.toTurns() - 0.5) <= c);
+                Assert.assertTrue(c <= (aB.toTurns() + 0.5));
+                double twoK = Math.rint((aA.toTurns() - c));
+                Assert.assertEquals(c, aA.toTurns() - twoK, 1e-14);
+            }
+        }
+    }
+
+    @Test
+    public void testNormalizeSimple1() {
+        final double value = 1.25;
+        final double expected = 0.25;
+        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double tol = Math.ulp(expected);
+        Assert.assertEquals(expected, actual, tol);
+    }
+    @Test
+    public void testNormalizeSimple2() {
+        final double value = 0.75;
+        final double expected = -0.25;
+        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double tol = Math.ulp(expected);
+        Assert.assertEquals(expected, actual, tol);
+    }
+    @Test
+    public void testNormalizeSimple3() {
+        final double value = 0.5 + 1e-10;
+        final double expected = -0.5 + 1e-10;
+        final double actual = PlaneAngle.ofTurns(value).normalize().toTurns();
+        final double tol = Math.ulp(expected);
+        Assert.assertEquals(expected, actual, tol);
+    }
+    @Test
+    public void testNormalizeSimple4() {
+        final double value = 5 * Math.PI / 4;
+        final double expected = Math.PI * (1d / 4 - 1);
+        final double actual = PlaneAngle.ofRadians(value).normalize().toRadians();
+        final double tol = Math.ulp(expected);
+        Assert.assertEquals(expected, actual, tol);
+    }
+
+    @Test
+    public void testHashCode() {
+        // Test assumes that the internal representation is in "turns".
+        final double value = -123.456789;
+        final int expected = new Double(value).hashCode();
+        final int actual = PlaneAngle.ofTurns(value).hashCode();
+        Assert.assertEquals(actual, expected);
+    }
+
+    @Test
+    public void testEquals1() {
+        final double value = 12345.6789;
+        final PlaneAngle a = PlaneAngle.ofRadians(value);
+        final PlaneAngle b = PlaneAngle.ofRadians(value);
+        Assert.assertTrue(a.equals(b));
+    }
+    @Test
+    public void testEquals2() {
+        final PlaneAngle a = PlaneAngle.ofRadians(153768.373486587);
+        final PlaneAngle b = null;
+        Assert.assertFalse(a.equals(b));
+    }
+    @Test
+    public void testEquals3() {
+        final double value = 0.987654321;
+        final PlaneAngle a = PlaneAngle.ofRadians(value);
+        final PlaneAngle b = PlaneAngle.ofRadians(value + 1e-16);
+        Assert.assertFalse(a.equals(b));
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/1aa1ddcd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9b19189..8aeafa1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -597,6 +597,7 @@
     <module>commons-numbers-primes</module>
     <module>commons-numbers-quaternion</module>
     <module>commons-numbers-fraction</module>
+    <module>commons-numbers-angle</module>
     <module>commons-numbers-gamma</module>
   </modules>