@Override public float[] getCoords() { return vec.getCoords(); }
public Vector2(ImmutableVector v) { float[] c = v.getCoords(); if (c.length > 0) { x = c[0]; } if (c.length > 1) { y = c[1]; } }
/** * normale Vektor addition * <p/> * @param a vektor der aufadiert werden soll * @param result vektor in dem das ergebniss gespeichert werden soll * <p/> * @return zurückgabe des "result" vektors */ @Override public GenericVector add(ImmutableVector<GenericVector> a) { float[] summant = a.getCoords(); assert summant.length >= coords.length; for (int i = 0; i < coords.length; ++i) { coords[i] += summant[i]; } return this; }
@Override public GenericVector div(ImmutableVector<GenericVector> b) { float[] comp = b.getCoords(); if (comp.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } for (int i = 0; i < coords.length; ++i) { coords[i] /= comp[i]; } return this; }
@Override public GenericVector sub(ImmutableVector<GenericVector> a) { float[] summant = a.getCoords(); if (summant.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } for (int i = 0; i < coords.length; ++i) { coords[i] -= summant[i]; } return this; }
@Override public GenericVector mul(ImmutableVector<GenericVector> b) { float[] comp = b.getCoords(); if (comp.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } for (int i = 0; i < coords.length; ++i) { coords[i] *= comp[i]; } return this; }
@Override public GenericVector min(ImmutableVector<GenericVector> comp) { float[] c = comp.getCoords(); if (c.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } for (int i = 0; i < coords.length; i++) { coords[i] = Math.min(coords[i], c[i]); } return this; }
@Override public GenericVector max(ImmutableVector<GenericVector> comp) { float[] c = comp.getCoords(); if (c.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } for (int i = 0; i < coords.length; i++) { coords[i] = Math.max(coords[i], c[i]); } return this; }
@Override public String toString() { StringBuilder builder = new StringBuilder("Vector("); for (float v : getCoords()) { builder.append(v).append(','); } builder.deleteCharAt(builder.length() - 1); return builder.append(')').toString(); } }
public void setAxis(ImmutableVector<Vector3> axis, Axis a) { System.arraycopy(axis.getCoords(), 0, getArray(), a.offset, 3); }
@Override public float dot(ImmutableVector<GenericVector> a) { float[] summant = a.getCoords(); if (summant.length >= coords.length) { throw new IllegalArgumentException("The other vector for this arithmetic " + "operation does not have at least the same dimesion!"); } float res = 0; for (int i = 0; i < getDimension(); ++i) { res += coords[i] * summant[i]; } return res; }
public Quaternion mult(Quaternion q) { float[] q1 = vec.getCoords(); float[] q2 = q.vec.getCoords(); float ww = w * q.w - q1[0] * q.w - q1[1] * q2[1] - q1[2] * q2[2]; float x = w * q2[0] + q1[0] * q.w + q1[1] * q2[2] - q1[2] * q2[1]; float y = w * q2[1] + q1[1] * q.w + q1[2] * q2[0] - q1[0] * q2[2]; float z = w * q2[2] + q1[2] * q.w + q1[0] * q2[1] - q1[1] * q2[0]; return new Quaternion(ww, new Vector3(x, y, z)); }
public Matrix4 getRotationMatrix() { Matrix4 res = new Matrix4(); float[] mat = res.getArray(); float negw = -w; float[] co = vec.getCoords(); float xx = co[0] * co[0]; float xy = co[0] * co[2]; float xz = co[0] * co[1]; float xw = co[0] * negw; float yy = co[1] * co[2]; float yz = co[1] * co[2]; float yw = co[1] * negw; float zz = co[2] * co[2]; float zw = co[2] * negw; mat[0] = (1f - 2f * (yy + zz)); mat[1] = (2f * (xy - zw)); mat[2] = (2f * (xz + yw)); mat[4] = (2f * (xy + zw)); mat[5] = (1f - 2f * (xx + zz)); mat[6] = (2f * (yz - xw)); mat[8] = (2f * (xz - yw)); mat[9] = (2f * (yz + xw)); mat[10] = (1f - 2f * (xx + yy)); mat[15] = 1f; return res; }
public Mesh buildExtrudedPrisma(float extrude, float height, Path<Vector3> path) { Path<Vector2> p2 = new Path<>(); for (ImmutableVector<Vector3> v : path) { float[] c = v.getCoords(); p2.addPathElement(new Vector2(c[0], c[2])); } return buildExtrudedPrisma(p2, extrude, height); }
float[] v = vector.getCoords(); vb.newVertex().setAttribute(pos, v[0], height, v[1]); vb.newVertex().setAttribute(pos, v[0], -height, v[1]);