lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [06/14] lucenenet git commit: Lucene.Net.Support.MathExtension: Renamed MathExtensions and added overloads of ToRadians() for decimal and int, and added the inverse ToDegrees() methods
Date Thu, 06 Jul 2017 13:07:03 GMT
Lucene.Net.Support.MathExtension: Renamed MathExtensions and added overloads of ToRadians()
for decimal and int, and added the inverse ToDegrees() methods


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/bfccac02
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/bfccac02
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/bfccac02

Branch: refs/heads/master
Commit: bfccac0261df6761700706007c4b3e42f0903b5b
Parents: 8543b7a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Jul 6 16:53:22 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Jul 6 16:53:22 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Lucene.Net.csproj         |  2 +-
 src/Lucene.Net/Support/MathExtension.cs  | 34 ----------
 src/Lucene.Net/Support/MathExtensions.cs | 93 +++++++++++++++++++++++++++
 src/Lucene.Net/Util/SloppyMath.cs        |  2 +-
 4 files changed, 95 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bfccac02/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index 2a6b11d..c0c02d3 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -679,7 +679,7 @@
     <Compile Include="Support\LinkedHashMap.cs" />
     <Compile Include="Support\ListExtensions.cs" />
     <Compile Include="Support\LurchTable.cs" />
-    <Compile Include="Support\MathExtension.cs" />
+    <Compile Include="Support\MathExtensions.cs" />
     <Compile Include="Support\IO\MemoryMappedFileByteBuffer.cs" />
     <Compile Include="Support\NumberFormat.cs" />
     <Compile Include="Support\PriorityQueue.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bfccac02/src/Lucene.Net/Support/MathExtension.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/MathExtension.cs b/src/Lucene.Net/Support/MathExtension.cs
deleted file mode 100644
index ce12d4a..0000000
--- a/src/Lucene.Net/Support/MathExtension.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-´╗┐using System;
-
-namespace Lucene.Net.Support
-{
-    /*
-	 * 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.
-	 */
-
-    public static class MathExtension
-    {
-        /// <summary>
-        /// Convert to Radians.
-        /// </summary>
-        /// <param name="val">The value to convert to radians</param>
-        /// <returns>The value in radians</returns>
-        public static double ToRadians(this double val)
-        {
-            return (Math.PI / 180) * val;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bfccac02/src/Lucene.Net/Support/MathExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/MathExtensions.cs b/src/Lucene.Net/Support/MathExtensions.cs
new file mode 100644
index 0000000..32da6f4
--- /dev/null
+++ b/src/Lucene.Net/Support/MathExtensions.cs
@@ -0,0 +1,93 @@
+´╗┐using System;
+
+namespace Lucene.Net.Support
+{
+    /*
+	 * 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.
+	 */
+
+    public static class MathExtensions
+    {
+        /// <summary>
+        /// Converts an angle measured in degrees to an approximately equivalent angle 
+        /// measured in radians. The conversion from degrees to radians is generally inexact.
+        /// </summary>
+        /// <param name="degrees">An angle in degrees to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static double ToRadians(this double degrees)
+        {
+            return degrees / 180 * Math.PI;
+        }
+
+        /// <summary>
+        /// Converts an angle measured in degrees to an approximately equivalent angle 
+        /// measured in radians. The conversion from degrees to radians is generally inexact.
+        /// </summary>
+        /// <param name="degrees">An angle in degrees to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static decimal ToRadians(this decimal degrees)
+        {
+            return degrees / (decimal)(180 * Math.PI);
+        }
+
+        /// <summary>
+        /// Converts an angle measured in degrees to an approximately equivalent angle 
+        /// measured in radians. The conversion from degrees to radians is generally inexact.
+        /// </summary>
+        /// <param name="degrees">An angle in degrees to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static double ToRadians(this int degrees)
+        {
+            return ((double)degrees) / 180 * Math.PI;
+        }
+
+        /// <summary>
+        /// Converts an angle measured in radians to an approximately equivalent angle 
+        /// measured in degrees. The conversion from radians to degrees is generally 
+        /// inexact; users should not expect Cos((90.0).ToRadians()) to exactly equal 0.0.
+        /// </summary>
+        /// <param name="radians">An angle in radians to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static double ToDegrees(this double radians)
+        {
+            return radians * 180 / Math.PI;
+        }
+
+        /// <summary>
+        /// Converts an angle measured in radians to an approximately equivalent angle 
+        /// measured in degrees. The conversion from radians to degrees is generally 
+        /// inexact; users should not expect Cos((90.0).ToRadians()) to exactly equal 0.0.
+        /// </summary>
+        /// <param name="radians">An angle in radians to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static decimal ToDegrees(this decimal radians)
+        {
+            return radians * 180 / (decimal)Math.PI;
+        }
+
+        /// <summary>
+        /// Converts an angle measured in radians to an approximately equivalent angle 
+        /// measured in degrees. The conversion from radians to degrees is generally 
+        /// inexact; users should not expect Cos((90.0).ToRadians()) to exactly equal 0.0.
+        /// </summary>
+        /// <param name="radians">An angle in radians to convert to radians</param>
+        /// <returns>The value in radians</returns>
+        public static double ToDegrees(this int radians)
+        {
+            return ((double)radians) * 180 / Math.PI;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bfccac02/src/Lucene.Net/Util/SloppyMath.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/SloppyMath.cs b/src/Lucene.Net/Util/SloppyMath.cs
index e7a3d09..bbcfa18 100644
--- a/src/Lucene.Net/Util/SloppyMath.cs
+++ b/src/Lucene.Net/Util/SloppyMath.cs
@@ -194,7 +194,7 @@ namespace Lucene.Net.Util
 
         // Supposed to be >= sin(77.2deg), as fdlibm code is supposed to work with values
> 0.975,
         // but seems to work well enough as long as value >= sin(25deg).
-        private static readonly double ASIN_MAX_VALUE_FOR_TABS = Math.Sin(MathExtension.ToRadians(73.0));
+        private static readonly double ASIN_MAX_VALUE_FOR_TABS = Math.Sin(73.0.ToRadians());
 
         private static readonly int ASIN_TABS_SIZE = (1 << 13) + 1;
         private static readonly double ASIN_DELTA = ASIN_MAX_VALUE_FOR_TABS / (ASIN_TABS_SIZE
- 1);


Mime
View raw message