Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8525c2d

Browse files
committed
Mirror 9 years of internal changes outward.
1 parent c28f287 commit 8525c2d

File tree

140 files changed

+48032
-7332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+48032
-7332
lines changed

.classpath

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
1+
# .gitignore file for the open-source s2-geometry-java repo.
22
build/
3+
target/
4+
.project
5+
.classpath

.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

build.xml

Lines changed: 0 additions & 98 deletions
This file was deleted.

lib/guava-r09.jar

-1.09 MB
Binary file not shown.

lib/jsr305.jar

-32.2 KB
Binary file not shown.

lib/junit.jar

-213 KB
Binary file not shown.

pom.xml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (C) 2018 Google, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
21+
<parent>
22+
<groupId>org.sonatype.oss</groupId>
23+
<artifactId>oss-parent</artifactId>
24+
<version>7</version>
25+
</parent>
26+
27+
<groupId>com.google.common.geometry</groupId>
28+
<artifactId>s2-geometry-library-java</artifactId>
29+
<version>HEAD-SNAPSHOT</version>
30+
<name>S2 Geometry Library for Java</name>
31+
<description>
32+
Core geometry libraries for Java.
33+
</description>
34+
35+
<properties>
36+
<maven.compiler.source>1.8</maven.compiler.source>
37+
<maven.compiler.target>1.8</maven.compiler.target>
38+
<guava.version>25.1-jre</guava.version>
39+
<jsr305.version>3.0.1</jsr305.version>
40+
<junit.version>4.13-SNAPSHOT</junit.version>
41+
</properties>
42+
43+
<scm>
44+
<url>https://github.com/google/s2-geometry-library-java</url>
45+
<connection>scm:git:git://github.com/google/s2-geometry-library-java.git</connection>
46+
<developerConnection>scm:git:ssh://[email protected]/google/s2-geometry-library-java.git</developerConnection>
47+
<tag>HEAD</tag>
48+
</scm>
49+
50+
<dependencies>
51+
<dependency>
52+
<groupId>com.google.guava</groupId>
53+
<artifactId>guava</artifactId>
54+
<version>${guava.version}</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.google.code.findbugs</groupId>
58+
<artifactId>jsr305</artifactId>
59+
<version>${jsr305.version}</version>
60+
<optional>true</optional>
61+
</dependency>
62+
<dependency>
63+
<groupId>junit</groupId>
64+
<artifactId>junit</artifactId>
65+
<version>${junit.version}</version>
66+
<scope>test</scope>
67+
</dependency>
68+
</dependencies>
69+
70+
<build>
71+
<sourceDirectory>src</sourceDirectory>
72+
<testSourceDirectory>tests</testSourceDirectory>
73+
74+
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-surefire-plugin</artifactId>
78+
<configuration>
79+
<excludes>
80+
<exclude>**/GeometryTestCase.java</exclude>
81+
</excludes>
82+
</configuration>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
</project>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright 2018 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.common.geometry;
17+
18+
import com.google.common.annotations.GwtCompatible;
19+
import com.google.common.base.Objects;
20+
import java.math.BigDecimal;
21+
22+
/** A point consisting of BigDecimal coordinates. */
23+
@GwtCompatible
24+
final strictfp class BigPoint implements Comparable<BigPoint> {
25+
final BigDecimal x;
26+
final BigDecimal y;
27+
final BigDecimal z;
28+
29+
/** Creates a point of BigDecimal coordinates from a point of double coordinates. */
30+
BigPoint(S2Point p) {
31+
this(Platform.newBigDecimal(p.x), Platform.newBigDecimal(p.y), Platform.newBigDecimal(p.z));
32+
}
33+
34+
/** Creates a point from the given BigDecimal coordinates. */
35+
BigPoint(BigDecimal x, BigDecimal y, BigDecimal z) {
36+
this.x = x;
37+
this.y = y;
38+
this.z = z;
39+
}
40+
41+
/** Returns an S2Point by rounding 'this' to double precision. */
42+
S2Point toS2Point() {
43+
return new S2Point(x.doubleValue(), y.doubleValue(), z.doubleValue());
44+
}
45+
46+
/** Returns the vector cross product of 'this' with 'that'. */
47+
BigPoint crossProd(BigPoint that) {
48+
return new BigPoint(
49+
y.multiply(that.z).subtract(z.multiply(that.y)),
50+
z.multiply(that.x).subtract(x.multiply(that.z)),
51+
x.multiply(that.y).subtract(y.multiply(that.x)));
52+
}
53+
54+
/** Returns the vector dot product of 'this' with 'that'. */
55+
BigDecimal dotProd(BigPoint that) {
56+
return x.multiply(that.x).add(y.multiply(that.y)).add(z.multiply(that.z));
57+
}
58+
59+
/** Returns the vector dot product of 'this' with 'that'. */
60+
BigDecimal dotProd(S2Point that) {
61+
return dotProd(new BigPoint(that));
62+
}
63+
64+
/** Returns true iff this and 'p' are exactly parallel or anti-parallel. */
65+
boolean isLinearlyDependent(BigPoint p) {
66+
BigPoint n = crossProd(p);
67+
return n.x.signum() == 0 && n.y.signum() == 0 && n.z.signum() == 0;
68+
}
69+
70+
/** Returns true iff this and 'p' are exactly anti-parallel, antipodal points. */
71+
boolean isAntipodal(BigPoint p) {
72+
return isLinearlyDependent(p) && dotProd(p).signum() < 0;
73+
}
74+
75+
/** Returns the square of the magnitude of this vector. */
76+
BigDecimal norm2() {
77+
return this.dotProd(this);
78+
}
79+
80+
@Override
81+
public int compareTo(BigPoint p) {
82+
int result = x.compareTo(p.x);
83+
if (result != 0) {
84+
return result;
85+
}
86+
result = y.compareTo(p.y);
87+
if (result != 0) {
88+
return result;
89+
}
90+
return z.compareTo(p.z);
91+
}
92+
93+
@Override
94+
public boolean equals(Object that) {
95+
if (!(that instanceof BigPoint)) {
96+
return false;
97+
}
98+
BigPoint thatPoint = (BigPoint) that;
99+
return x.equals(thatPoint.x) && y.equals(thatPoint.y) && z.equals(thatPoint.z);
100+
}
101+
102+
@Override
103+
public int hashCode() {
104+
return Objects.hashCode(x, y, z);
105+
}
106+
}

0 commit comments

Comments
 (0)