34 package eu.mihosoft.vrl.v3d;
36 import static java.lang.Math.abs;
37 import static java.lang.Math.acos;
38 import static java.lang.Math.max;
39 import static java.lang.Math.min;
40 import java.util.Random;
85 this.x =
x.doubleValue();
86 this.y =
y.doubleValue();
87 this.z =
z.doubleValue();
107 this(
x,
y, (double) 0);
123 return xy(
x.doubleValue(),
y.doubleValue());
231 return this.
x * a.
x + this.
y * a.
y + this.
z * a.
z;
257 return Math.sqrt(this.
dot(
this));
267 double magnitudeSq() {
268 return this.
dot(
this);
293 this.
y * a.
z -
this.
z * a.
y,
294 this.
z * a.
x -
this.
x * a.
z,
295 this.
x * a.
y -
this.
y * a.
x
305 return toStlString(
new StringBuilder()).toString();
315 return sb.append(this.
x).append(
" ").
316 append(this.
y).append(
" ").
326 return toObjString(
new StringBuilder()).toString();
336 return sb.append(this.
x).append(
" ").
337 append(this.
y).append(
" ").
394 return "[" +
x +
", " +
y +
", " +
z +
"]";
405 public boolean test(Object obj,
double epsilon) {
409 if (getClass() != obj.getClass()) {
413 if (abs(this.
x - other.
x) > epsilon) {
416 if (abs(this.
y - other.
y) > epsilon) {
419 if (abs(this.
z - other.
z) > epsilon) {
433 return acos(max(min(val, 1), -1));
442 hash = 97 * hash + (int) (Double.doubleToLongBits(
this.x) ^ (Double.doubleToLongBits(this.
x) >>> 32));
443 hash = 97 * hash + (int) (Double.doubleToLongBits(
this.y) ^ (Double.doubleToLongBits(this.
y) >>> 32));
444 hash = 97 * hash + (int) (Double.doubleToLongBits(
this.z) ^ (Double.doubleToLongBits(this.
z) >>> 32));
517 Random r =
new Random();
519 int numberOfZeroEntries = 0;
522 numberOfZeroEntries++;
527 numberOfZeroEntries++;
532 numberOfZeroEntries++;
536 switch (numberOfZeroEntries) {
553 o1 = (-this.
y * o2 - this.
z * o3) / this.
x;
569 o2 = -this.
z * o3 / this.
y;
571 }
else if (this.
y == 0) {
578 o1 = -this.
z * o3 / this.
x;
580 }
else if (this.
z == 0) {
587 o2 = -this.
z * o1 / this.
y;
607 System.err.println(
"This vector is equal to (0,0,0). ");
610 System.err.println(
"The orthogonal one is set randomly.");
626 while (this.
dot(result) != 0.0) {
static final double EPSILON_Point
static final long serialVersionUID
Vector3d cross(Vector3d a)
boolean equals(Object obj)
Vector3d(double x, double y, double z)
StringBuilder toObjString(StringBuilder sb)
Vector3d transform(Transform transform)
static Vector3d xyz(Number x, Number y, Number z)
StringBuilder toStlString(StringBuilder sb)
Vector3d(Number x, Number y)
static final Vector3d X_ONE
Vector3d plus(Vector3d v)
Vector3d transformed(Transform transform, double amount)
static Vector3d y(double y)
static Vector3d xyz(double x, double y, double z)
static Vector3d xy(double x, double y)
static final Vector3d UNITY
static final Vector3d ZERO
Vector3d minus(Vector3d v)
static Vector3d z(double z)
Vector3d transformed(Transform transform)
Vector3d(double x, double y)
Vector3d transform(Transform transform, double amount)
Vector3d(Number x, Number y, Number z)
boolean test(Object obj, double epsilon)
Vector3d lerp(Vector3d a, double t)
static Vector3d x(double x)
static Vector3d xy(Number x, Number y)
Vector3d dividedBy(double a)
static final Vector3d Z_ONE
Vector3d times(Vector3d a)
static final Vector3d Y_ONE