pbox2d 0.9.1-java → 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -5
- data/CHANGELOG.md +4 -0
- data/README.md +6 -6
- data/docs/.gitignore +6 -0
- data/docs/_classes/pbox2d.md +375 -0
- data/docs/_classes/world_builder.md +7 -0
- data/docs/_config.yml +32 -0
- data/docs/_includes/footer.html +55 -0
- data/docs/_includes/head.html +18 -0
- data/docs/_includes/header.html +27 -0
- data/docs/_includes/menu.html +8 -0
- data/docs/_includes/navigation.html +24 -0
- data/docs/_layouts/default.html +20 -0
- data/docs/_layouts/page.html +14 -0
- data/docs/_layouts/post.html +15 -0
- data/docs/_methods/init_options.md +28 -0
- data/docs/_methods/processing_to_world.md +29 -0
- data/docs/_methods/scale_to_processing.md +24 -0
- data/docs/_methods/scale_to_world.md +29 -0
- data/docs/_methods/step_options.md +25 -0
- data/docs/_methods/world_to_processing.md +30 -0
- data/docs/_modules/pb.md +25 -0
- data/docs/_modules/world_builder.md +26 -0
- data/docs/_posts/2016-10-14-welcome.md +183 -0
- data/docs/_sass/_base.scss +204 -0
- data/docs/_sass/_layout.scss +236 -0
- data/docs/_sass/_syntax-highlighting.scss +67 -0
- data/docs/about.md +20 -0
- data/docs/classes.html +9 -0
- data/docs/css/main.scss +52 -0
- data/docs/favicon.ico +0 -0
- data/docs/index.html +38 -0
- data/docs/methods.html +9 -0
- data/docs/modules.html +12 -0
- data/lib/pbox2d/version.rb +1 -1
- data/pbox2d.gemspec +4 -7
- data/pom.rb +8 -6
- data/pom.xml +3 -3
- data/src/org/jbox2d/collision/AABB.java +2 -2
- data/src/org/jbox2d/collision/Manifold.java +2 -2
- data/src/org/jbox2d/collision/ManifoldPoint.java +2 -2
- data/src/org/jbox2d/collision/shapes/MassData.java +1 -1
- data/src/org/jbox2d/common/Mat22.java +6 -13
- data/src/org/jbox2d/common/Mat33.java +253 -233
- data/src/org/jbox2d/common/MathUtils.java +5 -5
- data/src/org/jbox2d/common/Rot.java +16 -19
- data/src/org/jbox2d/common/Transform.java +4 -4
- data/src/org/jbox2d/common/Vec2.java +6 -12
- data/src/org/jbox2d/common/Vec3.java +147 -142
- data/src/org/jbox2d/dynamics/joints/DistanceJoint.java +4 -2
- metadata +62 -25
@@ -69,11 +69,11 @@ public class MathUtils extends PlatformMathUtils {
|
|
69
69
|
*/
|
70
70
|
public static final float RAD2DEG = 180 / PI;
|
71
71
|
|
72
|
-
public static final float[]
|
72
|
+
public static final float[] SIN_LUT = new float[Settings.SINCOS_LUT_LENGTH];
|
73
73
|
|
74
74
|
static {
|
75
75
|
for (int i = 0; i < Settings.SINCOS_LUT_LENGTH; i++) {
|
76
|
-
|
76
|
+
SIN_LUT[i] = (float) Math.sin(i * Settings.SINCOS_LUT_PRECISION);
|
77
77
|
}
|
78
78
|
}
|
79
79
|
|
@@ -104,13 +104,13 @@ public class MathUtils extends PlatformMathUtils {
|
|
104
104
|
|
105
105
|
// the next index is 0
|
106
106
|
if (index == Settings.SINCOS_LUT_LENGTH - 1) {
|
107
|
-
return ((1 - x) *
|
107
|
+
return ((1 - x) * SIN_LUT[index] + x * SIN_LUT[0]);
|
108
108
|
} else {
|
109
|
-
return ((1 - x) *
|
109
|
+
return ((1 - x) * SIN_LUT[index] + x * SIN_LUT[index + 1]);
|
110
110
|
}
|
111
111
|
|
112
112
|
} else {
|
113
|
-
return
|
113
|
+
return SIN_LUT[MathUtils.round(x / Settings.SINCOS_LUT_PRECISION) % Settings.SINCOS_LUT_LENGTH];
|
114
114
|
}
|
115
115
|
}
|
116
116
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*******************************************************************************
|
2
2
|
* Copyright (c) 2013, Daniel Murphy
|
3
3
|
* All rights reserved.
|
4
|
-
*
|
4
|
+
*
|
5
5
|
* Redistribution and use in source and binary forms, with or without modification,
|
6
6
|
* are permitted provided that the following conditions are met:
|
7
7
|
* * Redistributions of source code must retain the above copyright notice,
|
@@ -9,7 +9,7 @@
|
|
9
9
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
10
10
|
* this list of conditions and the following disclaimer in the documentation
|
11
11
|
* and/or other materials provided with the distribution.
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
14
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
15
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -27,7 +27,7 @@ import java.io.Serializable;
|
|
27
27
|
|
28
28
|
/**
|
29
29
|
* Represents a rotation
|
30
|
-
*
|
30
|
+
*
|
31
31
|
* @author Daniel
|
32
32
|
*/
|
33
33
|
public class Rot implements Serializable {
|
@@ -35,13 +35,18 @@ public class Rot implements Serializable {
|
|
35
35
|
|
36
36
|
public float s, c; // sin and cos
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
public Rot() {
|
39
|
+
setIdentity();
|
40
|
+
}
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
public Rot(float angle) {
|
43
|
+
set(angle);
|
44
|
+
}
|
45
|
+
|
46
|
+
public Rot(Rot rot) {
|
47
|
+
c = rot.c;
|
48
|
+
s = rot.s;
|
49
|
+
}
|
45
50
|
|
46
51
|
public float getSin() {
|
47
52
|
return s;
|
@@ -56,7 +61,7 @@ public class Rot implements Serializable {
|
|
56
61
|
return c;
|
57
62
|
}
|
58
63
|
|
59
|
-
public Rot set(float angle) {
|
64
|
+
public final Rot set(float angle) {
|
60
65
|
s = MathUtils.sin(angle);
|
61
66
|
c = MathUtils.cos(angle);
|
62
67
|
return this;
|
@@ -68,7 +73,7 @@ public class Rot implements Serializable {
|
|
68
73
|
return this;
|
69
74
|
}
|
70
75
|
|
71
|
-
public Rot setIdentity() {
|
76
|
+
public final Rot setIdentity() {
|
72
77
|
s = 0;
|
73
78
|
c = 1;
|
74
79
|
return this;
|
@@ -86,14 +91,6 @@ public class Rot implements Serializable {
|
|
86
91
|
yAxis.set(-s, c);
|
87
92
|
}
|
88
93
|
|
89
|
-
// @Override // annotation omitted for GWT-compatibility
|
90
|
-
public Rot clone() {
|
91
|
-
Rot copy = new Rot();
|
92
|
-
copy.s = s;
|
93
|
-
copy.c = c;
|
94
|
-
return copy;
|
95
|
-
}
|
96
|
-
|
97
94
|
public static final void mul(Rot q, Rot r, Rot out) {
|
98
95
|
float tempc = q.c * r.c - q.s * r.s;
|
99
96
|
out.s = q.s * r.c + q.c * r.s;
|
@@ -60,8 +60,8 @@ public class Transform implements Serializable {
|
|
60
60
|
* @param xf
|
61
61
|
*/
|
62
62
|
public Transform(final Transform xf) {
|
63
|
-
p = xf.p
|
64
|
-
q = xf.q
|
63
|
+
p = new Vec2(xf.p);
|
64
|
+
q = new Rot(xf.q);
|
65
65
|
}
|
66
66
|
|
67
67
|
/**
|
@@ -71,8 +71,8 @@ public class Transform implements Serializable {
|
|
71
71
|
* @param _R
|
72
72
|
*/
|
73
73
|
public Transform(final Vec2 _position, final Rot _R) {
|
74
|
-
p = _position
|
75
|
-
q = _R
|
74
|
+
p = new Vec2(_position);
|
75
|
+
q = new Rot(_R);
|
76
76
|
}
|
77
77
|
|
78
78
|
/**
|
@@ -32,7 +32,9 @@ import java.io.Serializable;
|
|
32
32
|
*/
|
33
33
|
public class Vec2 implements Serializable {
|
34
34
|
|
35
|
-
private static final long serialVersionUID =
|
35
|
+
private static final long serialVersionUID = -8868057637176265779L;
|
36
|
+
|
37
|
+
|
36
38
|
|
37
39
|
public float x, y;
|
38
40
|
|
@@ -262,17 +264,6 @@ public class Vec2 implements Serializable {
|
|
262
264
|
y = MathUtils.abs(y);
|
263
265
|
}
|
264
266
|
|
265
|
-
// @Override // annotation omitted for GWT-compatibility
|
266
|
-
/**
|
267
|
-
* Return a copy of this vector.
|
268
|
-
*
|
269
|
-
* @return
|
270
|
-
*/
|
271
|
-
@Override
|
272
|
-
public final Vec2 clone() {
|
273
|
-
return new Vec2(x, y);
|
274
|
-
}
|
275
|
-
|
276
267
|
@Override
|
277
268
|
public final String toString() {
|
278
269
|
return "(" + x + "," + y + ")";
|
@@ -354,6 +345,7 @@ public class Vec2 implements Serializable {
|
|
354
345
|
}
|
355
346
|
|
356
347
|
/**
|
348
|
+
* @return
|
357
349
|
* @see java.lang.Object#hashCode()
|
358
350
|
*/
|
359
351
|
@Override
|
@@ -366,6 +358,8 @@ public class Vec2 implements Serializable {
|
|
366
358
|
}
|
367
359
|
|
368
360
|
/**
|
361
|
+
* @param obj
|
362
|
+
* @return
|
369
363
|
* @see java.lang.Object#equals(java.lang.Object)
|
370
364
|
*/
|
371
365
|
@Override
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
/** *****************************************************************************
|
2
2
|
* Copyright (c) 2013, Daniel Murphy
|
3
3
|
* All rights reserved.
|
4
|
-
*
|
4
|
+
*
|
5
5
|
* Redistribution and use in source and binary forms, with or without modification,
|
6
6
|
* are permitted provided that the following conditions are met:
|
7
7
|
* * Redistributions of source code must retain the above copyright notice,
|
@@ -9,7 +9,7 @@
|
|
9
9
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
10
10
|
* this list of conditions and the following disclaimer in the documentation
|
11
11
|
* and/or other materials provided with the distribution.
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
14
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
15
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -20,7 +20,7 @@
|
|
20
20
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
21
21
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
22
22
|
* POSSIBILITY OF SUCH DAMAGE.
|
23
|
-
|
23
|
+
***************************************************************************** */
|
24
24
|
package org.jbox2d.common;
|
25
25
|
|
26
26
|
import java.io.Serializable;
|
@@ -29,142 +29,147 @@ import java.io.Serializable;
|
|
29
29
|
* @author Daniel Murphy
|
30
30
|
*/
|
31
31
|
public class Vec3 implements Serializable {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
final
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
out
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
32
|
+
|
33
|
+
private static final long serialVersionUID = 102913558223451982L;
|
34
|
+
public float x, y, z;
|
35
|
+
|
36
|
+
public Vec3() {
|
37
|
+
x = y = z = 0f;
|
38
|
+
}
|
39
|
+
|
40
|
+
public Vec3(float argX, float argY, float argZ) {
|
41
|
+
x = argX;
|
42
|
+
y = argY;
|
43
|
+
z = argZ;
|
44
|
+
}
|
45
|
+
|
46
|
+
public Vec3(Vec3 copy) {
|
47
|
+
x = copy.x;
|
48
|
+
y = copy.y;
|
49
|
+
z = copy.z;
|
50
|
+
}
|
51
|
+
|
52
|
+
public Vec3 set(Vec3 vec) {
|
53
|
+
x = vec.x;
|
54
|
+
y = vec.y;
|
55
|
+
z = vec.z;
|
56
|
+
return this;
|
57
|
+
}
|
58
|
+
|
59
|
+
public Vec3 set(float argX, float argY, float argZ) {
|
60
|
+
x = argX;
|
61
|
+
y = argY;
|
62
|
+
z = argZ;
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
|
66
|
+
public Vec3 addLocal(Vec3 argVec) {
|
67
|
+
x += argVec.x;
|
68
|
+
y += argVec.y;
|
69
|
+
z += argVec.z;
|
70
|
+
return this;
|
71
|
+
}
|
72
|
+
|
73
|
+
public Vec3 add(Vec3 argVec) {
|
74
|
+
return new Vec3(x + argVec.x, y + argVec.y, z + argVec.z);
|
75
|
+
}
|
76
|
+
|
77
|
+
public Vec3 subLocal(Vec3 argVec) {
|
78
|
+
x -= argVec.x;
|
79
|
+
y -= argVec.y;
|
80
|
+
z -= argVec.z;
|
81
|
+
return this;
|
82
|
+
}
|
83
|
+
|
84
|
+
public Vec3 sub(Vec3 argVec) {
|
85
|
+
return new Vec3(x - argVec.x, y - argVec.y, z - argVec.z);
|
86
|
+
}
|
87
|
+
|
88
|
+
public Vec3 mulLocal(float argScalar) {
|
89
|
+
x *= argScalar;
|
90
|
+
y *= argScalar;
|
91
|
+
z *= argScalar;
|
92
|
+
return this;
|
93
|
+
}
|
94
|
+
|
95
|
+
public Vec3 mul(float argScalar) {
|
96
|
+
return new Vec3(x * argScalar, y * argScalar, z * argScalar);
|
97
|
+
}
|
98
|
+
|
99
|
+
public Vec3 negate() {
|
100
|
+
return new Vec3(-x, -y, -z);
|
101
|
+
}
|
102
|
+
|
103
|
+
public Vec3 negateLocal() {
|
104
|
+
x = -x;
|
105
|
+
y = -y;
|
106
|
+
z = -z;
|
107
|
+
return this;
|
108
|
+
}
|
109
|
+
|
110
|
+
public void setZero() {
|
111
|
+
x = 0;
|
112
|
+
y = 0;
|
113
|
+
z = 0;
|
114
|
+
}
|
115
|
+
|
116
|
+
@Override
|
117
|
+
public String toString() {
|
118
|
+
return "(" + x + "," + y + "," + z + ")";
|
119
|
+
}
|
120
|
+
|
121
|
+
@Override
|
122
|
+
public int hashCode() {
|
123
|
+
final int prime = 31;
|
124
|
+
int result = 1;
|
125
|
+
result = prime * result + Float.floatToIntBits(x);
|
126
|
+
result = prime * result + Float.floatToIntBits(y);
|
127
|
+
result = prime * result + Float.floatToIntBits(z);
|
128
|
+
return result;
|
129
|
+
}
|
130
|
+
|
131
|
+
@Override
|
132
|
+
public boolean equals(Object obj) {
|
133
|
+
if (this == obj) {
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
if (obj == null) {
|
137
|
+
return false;
|
138
|
+
}
|
139
|
+
if (getClass() != obj.getClass()) {
|
140
|
+
return false;
|
141
|
+
}
|
142
|
+
Vec3 other = (Vec3) obj;
|
143
|
+
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) {
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) {
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
return (Float.floatToIntBits(z) == Float.floatToIntBits(other.z));
|
150
|
+
}
|
151
|
+
|
152
|
+
public final static float dot(Vec3 a, Vec3 b) {
|
153
|
+
return a.x * b.x + a.y * b.y + a.z * b.z;
|
154
|
+
}
|
155
|
+
|
156
|
+
public final static Vec3 cross(Vec3 a, Vec3 b) {
|
157
|
+
return new Vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
|
158
|
+
}
|
159
|
+
|
160
|
+
public final static void crossToOut(Vec3 a, Vec3 b, Vec3 out) {
|
161
|
+
final float tempy = a.z * b.x - a.x * b.z;
|
162
|
+
final float tempz = a.x * b.y - a.y * b.x;
|
163
|
+
out.x = a.y * b.z - a.z * b.y;
|
164
|
+
out.y = tempy;
|
165
|
+
out.z = tempz;
|
166
|
+
}
|
167
|
+
|
168
|
+
public final static void crossToOutUnsafe(Vec3 a, Vec3 b, Vec3 out) {
|
169
|
+
assert (out != b);
|
170
|
+
assert (out != a);
|
171
|
+
out.x = a.y * b.z - a.z * b.y;
|
172
|
+
out.y = a.z * b.x - a.x * b.z;
|
173
|
+
out.z = a.x * b.y - a.y * b.x;
|
174
|
+
}
|
170
175
|
}
|