@Override public Vector2 sub(ImmutableVector<Vector2> b) { Vector2 sum = b.clone(); x -= sum.x; y -= sum.y; return this; }
@Override public E clone() { return vec.clone(); } }
@Override public Vector2 div(ImmutableVector<Vector2> b) { Vector2 sum = b.clone(); x /= sum.x; y /= sum.y; return this; }
@Override public Vector3 add(ImmutableVector<Vector3> b) { Vector3 sum = b.clone(); x += sum.x; y += sum.y; z += sum.z; return this; }
@Override public Vector2 min(ImmutableVector<Vector2> b) { Vector2 sum = b.clone(); x = Math.min(x, sum.x); y = Math.min(y, sum.y); return this; }
@Override public Vector3 max(ImmutableVector<Vector3> b) { Vector3 sum = b.clone(); x = Math.max(x, sum.x); y = Math.max(y, sum.y); z = Math.max(z, sum.z); return this; }
@Override public Vector3 min(ImmutableVector<Vector3> b) { Vector3 sum = b.clone(); x = Math.min(x, sum.x); y = Math.min(y, sum.y); z = Math.min(z, sum.z); return this; }
public void setLightDir(ImmutableVector<Vector3> lightDir) { this.lightDir = lightDir.clone(); updateLight(lightDir); }
public Vector3 getRotationAxis() { Quaternion q = normalize(); double sin_a = sqrt(1. - w * w); if (abs(sin_a) < 0.0005) { sin_a = 1; } return q.vec.clone().mul((float) (1. / sin_a)); }
public E reflect(ImmutableVector<E> normal) { E n = normal.clone(); n.mul(dot(n) * 2); sub(n); return (E) this; }
@Override public void setPosition(ImmutableVector<Vector3> newpos) { newpos.clone().sub(getPosition()); matrix.worldTranslate(newpos); }
public Vector3 getIntersection(Line<Vector3> g) { float NdotD = g.getDirection().dot(normal); if (NdotD == 0) { throw new IllegalArgumentException("There is no intersecting point when a line is parallel to a plane"); } float delta = (-nDot - g.getStartingPoint().dot(normal)) / NdotD; return g.getStartingPoint().clone().add(g.getDirection().clone().mul(delta)); }
public Line<Vector3> getSchnittKante(Plane e) { Vector3 dir = normal.toVector3().cross(e.normal); float dot = normal.dot(e.normal); float tmp = 1 / (1 - dot * dot); float c1 = (e.nDot * dot - nDot) * tmp; float c2 = (nDot * dot - e.nDot) * tmp; Vector3 a = normal.clone().mul(c1); a.add(e.normal.clone().mul(c2)); return new Line(a, dir); }
/** * translate the matrix in world space * <p/> * @param vec translation vector * <p/> * @return the manipulated matrix */ public Matrix4 worldTranslate(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return worldTranslate(t.getX(), t.getY(), t.getZ()); }
/** * scales the matrix space * <p/> * @param scale scale factor vector * <p/> * @return the manipulated matrix */ public Matrix4 scale(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return scale(t.getX(), t.getY(), t.getZ()); }
public double distanceTo(Line<E> g) { if (isParallelTo(g)) { return distanceTo(g.a); } else { //TODO Vector3 n = dir.toVector3().cross(g.dir.toVector3()).normalize(); return Math.abs(a.clone().sub(g.a).toVector3().dot(n)); } }
public static <E extends Vector<E>> Plane fromPointAndLine( ImmutableVector<E> start, Line<E> g) { return new Plane(start, start.clone().sub(g.getStartingPoint()).toVector3().cross(g.getDirection().toVector3())); }