blob: b16a356247e4cddcdb90f712e360b3f24585ad0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|
package ru.olamedia.math;
public class Vector3f {
public float x;
public float y;
public float z;
public Vector3f() {
this(0, 0, 0);
}
public Vector3f(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3f(Vector3f vector) {
this(vector.x, vector.y, vector.z);
}
public float dot(Vector3f v) {
return (x * v.x + y * v.y + z * v.z);
}
public Vector3f cross(Vector3f n) {
Vector3f r = new Vector3f(y * n.z - z * n.y, z * n.x - x * n.z, x * n.y - y * n.x);
return r;
}
public Vector3f add(Vector3f n) {
Vector3f r = new Vector3f(x + n.x, y + n.y, z + n.z);
return r;
}
public Vector3f sub(Vector3f n) {
return add(n.negate());
}
public Vector3f negate() {
Vector3f n = new Vector3f(this);
n.x = -n.x;
n.y = -n.y;
n.z = -n.z;
return n;
}
public Vector3f translate(Vector3f look, float f) {
Vector3f v = new Vector3f(this);
v.x += look.x * f;
v.y += look.y * f;
v.z += look.z * f;
return v;
}
public Vector3f translate(javax.vecmath.Vector3f look, float f) {
Vector3f v = new Vector3f(this);
v.x += look.x * f;
v.y += look.y * f;
v.z += look.z * f;
return v;
}
public void set(Vector3f vn) {
x = vn.x;
y = vn.y;
z = vn.z;
}
}
|