You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2018/02/13 14:53:29 UTC
[1/2] lucene-solr:master: LUCENE-8171: Refactor vector constructor to
support later changes, and add an ignored test for a precision issue.
Repository: lucene-solr
Updated Branches:
refs/heads/master 904030778 -> 8a5a4a631
LUCENE-8171: Refactor vector constructor to support later changes, and add an ignored test for a precision issue.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4f351fd2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4f351fd2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4f351fd2
Branch: refs/heads/master
Commit: 4f351fd21bdbec2bf6a27bb6014bb1d8e511ee92
Parents: 277097c
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Feb 13 09:53:04 2018 -0500
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Feb 13 09:53:04 2018 -0500
----------------------------------------------------------------------
.../lucene/spatial3d/geom/SidedPlane.java | 39 ++++++++++++++++----
.../apache/lucene/spatial3d/geom/Vector.java | 32 ++++++++++++----
.../lucene/spatial3d/geom/RandomPlaneTest.java | 28 ++++++++++++++
3 files changed, 85 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4f351fd2/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
index 404135a..9eb2040 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
@@ -177,14 +177,39 @@ public class SidedPlane extends Plane implements Membership {
*/
public static SidedPlane constructNormalizedThreePointSidedPlane(final Vector insidePoint,
final Vector point1, final Vector point2, final Vector point3) {
- try {
- final Vector planeNormal = new Vector(
- new Vector(point1.x - point2.x, point1.y - point2.y, point1.z - point2.z),
- new Vector(point2.x - point3.x, point2.y - point3.y, point2.z - point3.z));
- return new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point2));
- } catch (IllegalArgumentException e) {
- return null;
+ SidedPlane rval = null;
+
+ if (rval == null) {
+ try {
+ final Vector planeNormal = new Vector(
+ point1.x - point2.x, point1.y - point2.y, point1.z - point2.z,
+ point2.x - point3.x, point2.y - point3.y, point2.z - point3.z);
+ rval = new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point2));
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ if (rval == null) {
+ try {
+ final Vector planeNormal = new Vector(
+ point1.x - point3.x, point1.y - point3.y, point1.z - point3.z,
+ point3.x - point2.x, point3.y - point2.y, point3.z - point2.z);
+ rval = new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point3));
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ if (rval == null) {
+ try {
+ final Vector planeNormal = new Vector(
+ point3.x - point1.x, point3.y - point1.y, point3.z - point1.z,
+ point1.x - point2.x, point1.y - point2.y, point1.z - point2.z);
+ rval = new SidedPlane(insidePoint, planeNormal, -planeNormal.dotProduct(point1));
+ } catch (IllegalArgumentException e) {
+ }
}
+
+ return rval;
}
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4f351fd2/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
index f901d29..5209df8 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
@@ -73,6 +73,24 @@ public class Vector {
*/
public Vector(final Vector A, final double BX, final double BY, final double BZ) {
// We're really looking at two vectors and computing a perpendicular one from that.
+ this(A.x, A.y, A.z, BX, BY, BZ);
+ }
+
+ /**
+ * Construct a vector that is perpendicular to
+ * two other (non-zero) vectors. If the vectors are parallel,
+ * IllegalArgumentException will be thrown.
+ * Produces a normalized final vector.
+ *
+ * @param AX is the X value of the first
+ * @param AY is the Y value of the first
+ * @param AZ is the Z value of the first
+ * @param BX is the X value of the second
+ * @param BY is the Y value of the second
+ * @param BZ is the Z value of the second
+ */
+ public Vector(final double AX, final double AY, final double AZ, final double BX, final double BY, final double BZ) {
+ // We're really looking at two vectors and computing a perpendicular one from that.
// We can think of this as having three points -- the origin, and two points that aren't the origin.
// Normally, we can compute the perpendicular vector this way:
// x = u2v3 - u3v2
@@ -83,9 +101,9 @@ public class Vector {
// Gram-Schmidt process: https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
// Compute the naive perpendicular
- final double thisX = A.y * BZ - A.z * BY;
- final double thisY = A.z * BX - A.x * BZ;
- final double thisZ = A.x * BY - A.y * BX;
+ final double thisX = AY * BZ - AZ * BY;
+ final double thisY = AZ * BX - AX * BZ;
+ final double thisZ = AX * BY - AY * BX;
final double magnitude = magnitude(thisX, thisY, thisZ);
if (magnitude < MINIMUM_RESOLUTION) {
@@ -103,7 +121,7 @@ public class Vector {
// we need to adjust
int i = 0;
while (true) {
- final double currentDotProdA = A.x * normalizeX + A.y * normalizeY + A.z * normalizeZ;
+ final double currentDotProdA = AX * normalizeX + AY * normalizeY + AZ * normalizeZ;
final double currentDotProdB = BX * normalizeX + BY * normalizeY + BZ * normalizeZ;
if (Math.abs(currentDotProdA) < MINIMUM_RESOLUTION && Math.abs(currentDotProdB) < MINIMUM_RESOLUTION) {
break;
@@ -114,9 +132,9 @@ public class Vector {
final double currentVectorZ;
final double currentDotProd;
if (Math.abs(currentDotProdA) > Math.abs(currentDotProdB)) {
- currentVectorX = A.x;
- currentVectorY = A.y;
- currentVectorZ = A.z;
+ currentVectorX = AX;
+ currentVectorY = AY;
+ currentVectorZ = AZ;
currentDotProd = currentDotProdA;
} else {
currentVectorX = BX;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4f351fd2/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
index 42f09e3..8c94c9c 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
@@ -22,6 +22,7 @@ import java.util.List;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.junit.Test;
+import org.junit.Ignore;
/**
* Random test for planes.
@@ -50,6 +51,33 @@ public class RandomPlaneTest extends RandomGeo3dShapeGenerator {
}
}
}
+
+ @Ignore
+ @Test
+ @Repeat(iterations = 10)
+ public void testPlaneThreePointsAccuracy() {
+ PlanetModel planetModel = randomPlanetModel();
+ for (int i= 0; i < 1000; i++) {
+ GeoPoint point1 = randomGeoPoint(planetModel);
+ double dist = random().nextDouble() * Math.PI - Vector.MINIMUM_ANGULAR_RESOLUTION;
+ double bearing = random().nextDouble() * 2 * Math.PI;
+ GeoPoint point2 = planetModel.surfacePointOnBearing(point1, dist, bearing );
+ dist = random().nextDouble() * Vector.MINIMUM_ANGULAR_RESOLUTION + Vector.MINIMUM_ANGULAR_RESOLUTION;
+ bearing = random().nextDouble() * 2 * Math.PI;
+ GeoPoint point3 = planetModel.surfacePointOnBearing(point1, dist, bearing );
+ GeoPoint check = randomGeoPoint(planetModel);
+ SidedPlane plane = SidedPlane.constructNormalizedThreePointSidedPlane(check, point1, point2, point3);
+ String msg = planetModel + " point 1: " + point1 + ", point 2: " + point2 + ", point 3: " + point3 + " , check: " + check;
+ if (plane == null) {
+ fail(msg);
+ }
+ assertTrue(plane.evaluate(check) + " " + msg, plane.isWithin(check));
+ assertTrue(plane.evaluate(point1) + " " +msg, plane.isWithin(point3));
+ assertTrue(plane.evaluate(point2) + " " +msg, plane.isWithin(point2));
+ assertTrue(plane.evaluate(point3) + " " +msg, plane.isWithin(point1));
+ }
+ }
+
@Test
[2/2] lucene-solr:master: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by kw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8a5a4a63
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8a5a4a63
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8a5a4a63
Branch: refs/heads/master
Commit: 8a5a4a6317e272cdda316a54fa74f60fa82f1497
Parents: 4f351fd 9040307
Author: Karl Wright <Da...@gmail.com>
Authored: Tue Feb 13 09:53:19 2018 -0500
Committer: Karl Wright <Da...@gmail.com>
Committed: Tue Feb 13 09:53:19 2018 -0500
----------------------------------------------------------------------
build.xml | 250 +------------------
dev-tools/maven/README.maven | 12 +
lucene/CHANGES.txt | 20 ++
lucene/benchmark/src/test/conf/ConfLoader.java | 21 --
.../benchmark/byTask/TestPerfTasksParse.java | 4 +-
lucene/build.xml | 2 -
lucene/common-build.xml | 138 +---------
.../org/apache/lucene/index/FieldInfos.java | 57 ++---
.../apache/lucene/index/FilteredTermsEnum.java | 4 +-
.../org/apache/lucene/search/BooleanQuery.java | 3 +
.../org/apache/lucene/index/TestFieldInfos.java | 92 +++++++
.../search/join/GlobalOrdinalsCollector.java | 10 +-
.../lucene/search/join/GlobalOrdinalsQuery.java | 16 +-
.../join/GlobalOrdinalsWithScoreCollector.java | 20 +-
.../join/GlobalOrdinalsWithScoreQuery.java | 12 +-
.../org/apache/lucene/search/join/JoinUtil.java | 15 +-
.../lucene/search/join/TermsCollector.java | 5 +-
.../search/join/TermsWithScoreCollector.java | 20 +-
.../apache/lucene/search/join/TestJoinUtil.java | 10 +-
.../function/TestDocValuesFieldSources.java | 4 +
lucene/tools/build.xml | 3 +
lucene/tools/clover/README.txt | 108 --------
lucene/tools/clover/clover.license | 5 -
.../src/groovy/check-source-patterns.groovy | 189 ++++++++++++++
.../tools/src/groovy/check-working-copy.groovy | 61 +++++
.../src/groovy/install-markdown-filter.groovy | 61 +++++
.../tools/src/groovy/patch-mrjar-classes.groovy | 10 +
lucene/tools/src/groovy/run-beaster.groovy | 71 ++++++
lucene/tools/src/groovy/run-maven-build.groovy | 49 ++++
solr/CHANGES.txt | 8 +
solr/build.xml | 2 -
solr/common-build.xml | 5 +-
.../solr/handler/admin/ClusterStatus.java | 5 +-
.../solr/handler/component/ExpandComponent.java | 13 +-
.../handler/component/RangeFacetProcessor.java | 3 +
.../apache/solr/schema/SortableTextField.java | 4 +-
.../solr/search/CollapsingQParserPlugin.java | 103 ++------
.../org/apache/solr/search/FastLRUCache.java | 4 +-
.../solr/search/IGainTermsQParserPlugin.java | 6 +-
.../java/org/apache/solr/search/LFUCache.java | 4 +-
.../java/org/apache/solr/search/LRUCache.java | 4 +-
.../org/apache/solr/search/PointMerger.java | 2 +
.../TextLogisticRegressionQParserPlugin.java | 6 +-
.../facet/FacetFieldProcessorByHashDV.java | 10 +-
.../org/apache/solr/search/facet/MinMaxAgg.java | 5 +-
.../solr/search/facet/UniqueMultiDvSlotAcc.java | 5 +-
.../apache/solr/servlet/SolrDispatchFilter.java | 5 +
.../solr/uninverting/UninvertingReader.java | 19 ++
.../apache/solr/update/SolrCmdDistributor.java | 20 +-
.../configsets/_default/conf/managed-schema | 24 ++
.../test/SecureRandomAlgorithmTesterApp.java | 41 ---
.../api/collections/TestCollectionAPI.java | 24 ++
.../solr/search/TestCollapseQParserPlugin.java | 1 +
.../apache/solr/search/TestRankQueryPlugin.java | 6 +-
.../configsets/_default/conf/managed-schema | 24 ++
.../conf/managed-schema | 30 ++-
.../client/solrj/impl/XMLResponseParser.java | 18 ++
solr/test-framework/build.xml | 5 +-
58 files changed, 864 insertions(+), 814 deletions(-)
----------------------------------------------------------------------