/** * Creates a vector from three components. */ public Vector3 (float x, float y, float z) { set(x, y, z); }
/** * Sets the parameters of the plane. * * @return a reference to this plane (for chaining). */ public Plane set (float a, float b, float c, float d) { _normal.set(a, b, c); constant = d; return this; }
/** * Creates a vector from three components. */ public Vector3 (float x, float y, float z) { set(x, y, z); }
/** * Copy constructor. */ public Vector3 (IVector3 other) { set(other); }
/** * Creates a vector from an array of values. */ public Vector3 (float[] values) { set(values); }
/** * Copy constructor. */ public Vector3 (IVector3 other) { set(other); }
@Override // from IBox public Box add (IVector3 point, Box result) { result._minExtent.set( Math.min(_minExtent.x, point.x()), Math.min(_minExtent.y, point.y()), Math.min(_minExtent.z, point.z())); result._maxExtent.set( Math.max(_maxExtent.x, point.x()), Math.max(_maxExtent.y, point.y()), Math.max(_maxExtent.z, point.z())); return result; }
@Override // from IMatrix3 public Vector3 transform (IVector3 vector, Vector3 result) { float vx = vector.x(), vy = vector.y(), vz = vector.z(); return result.set(m00*vx + m10*vy + m20*vz, m01*vx + m11*vy + m21*vz, m02*vx + m12*vy + m22*vz); }
@Override // from interface IVector3 public Vector3 cross (IVector3 other, Vector3 result) { float x = this.x, y = this.y, z = this.z; float ox = other.x(), oy = other.y(), oz = other.z(); return result.set(y*oz - z*oy, z*ox - x*oz, x*oy - y*ox); }
@Override // from IMatrix4 public Vector3 transformVector (IVector3 vector, Vector3 result) { float vx = vector.x(), vy = vector.y(), vz = vector.z(); return result.set(m00*vx + m10*vy + m20*vz, m01*vx + m11*vy + m21*vz, m02*vx + m12*vy + m22*vz); }
/** * Copies the elements of another vector. * * @return a reference to this vector, for chaining. */ public Vector3 set (IVector3 other) { return set(other.x(), other.y(), other.z()); }
@Override // from IMatrix4 public Vector3 transformPoint (IVector3 point, Vector3 result) { float px = point.x(), py = point.y(), pz = point.z(); return result.set(m00*px + m10*py + m20*pz + m30, m01*px + m11*py + m21*pz + m31, m02*px + m12*py + m22*pz + m32); }
@Override // from interface IVector3 public Vector3 cross (IVector3 other, Vector3 result) { float x = this.x, y = this.y, z = this.z; float ox = other.x(), oy = other.y(), oz = other.z(); return result.set(y*oz - z*oy, z*ox - x*oz, x*oy - y*ox); }
@Override // from IQuaternion public Vector3 transform (IVector3 vector, Vector3 result) { float xx = x*x, yy = y*y, zz = z*z; float xy = x*y, xz = x*z, xw = x*w; float yz = y*z, yw = y*w, zw = z*w; float vx = vector.x(), vy = vector.y(), vz = vector.z(); float vx2 = vx*2f, vy2 = vy*2f, vz2 = vz*2f; return result.set(vx + vy2*(xy - zw) + vz2*(xz + yw) - vx2*(yy + zz), vy + vx2*(xy + zw) + vz2*(yz - xw) - vy2*(xx + zz), vz + vx2*(xz - yw) + vy2*(yz + xw) - vz2*(xx + yy)); }
@Override // from IMatrix4 public Vector3 transformVector (IVector3 vector, Vector3 result) { float vx = vector.x(), vy = vector.y(), vz = vector.z(); return result.set(m00*vx + m10*vy + m20*vz, m01*vx + m11*vy + m21*vz, m02*vx + m12*vy + m22*vz); }
@Override // from interface IVector3 public Vector3 lerp (IVector3 other, float t, Vector3 result) { float x = this.x, y = this.y, z = this.z; return result.set(x + t*(other.x() - x), y + t*(other.y() - y), z + t*(other.z() - z)); }
@Override // from IQuaternion public Vector3 transformAndAdd (IVector3 vector, IVector3 add, Vector3 result) { float xx = x*x, yy = y*y, zz = z*z; float xy = x*y, xz = x*z, xw = x*w; float yz = y*z, yw = y*w, zw = z*w; float vx = vector.x(), vy = vector.y(), vz = vector.z(); float vx2 = vx*2f, vy2 = vy*2f, vz2 = vz*2f; return result.set(vx + vy2*(xy - zw) + vz2*(xz + yw) - vx2*(yy + zz) + add.x(), vy + vx2*(xy + zw) + vz2*(yz - xw) - vy2*(xx + zz) + add.y(), vz + vx2*(xz - yw) + vy2*(yz + xw) - vz2*(xx + yy) + add.z()); }