@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; }
/** * Sets this to a skew by the specified amount relative to the given plane. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToSkew (IVector3 normal, float constant, IVector3 amount) { return setToSkew(normal.x(), normal.y(), normal.z(), constant, amount.x(), amount.y(), amount.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()); }
/** * Sets this quaternion to the rotation described by the given angle and normalized * axis. * * @return a reference to this quaternion, for chaining. */ public Quaternion fromAngleAxis (float angle, IVector3 axis) { return fromAngleAxis(angle, axis.x(), axis.y(), axis.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); }
/** * Sets this quaternion to the rotation of (0, 0, -1) onto the supplied normalized vector. * * @return a reference to the quaternion, for chaining. */ public Quaternion fromVectorFromNegativeZ (IVector3 to) { return fromVectorFromNegativeZ(to.x(), to.y(), to.z()); }
/** * Sets this to a translation matrix. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToTranslation (IVector3 translation) { return setToTranslation(translation.x(), translation.y(), translation.z()); }
/** * Sets the translation component of this matrix. * * @return a reference to this matrix, for chaining. */ public Matrix4 setTranslation (IVector3 translation) { return setTranslation(translation.x(), translation.y(), translation.z()); }
/** * Sets this to a reflection across a plane intersecting the origin with the supplied normal. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToReflection (IVector3 normal) { return setToReflection(normal.x(), normal.y(), normal.z()); }
@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 float transformZ (IVector3 vector) { return vector.z() + vector.x()*2f*(x*z - y*w) + vector.y()*2f*(y*z + x*w) - vector.z()*2f*(x*x + y*y); }
@Override // from IBox public boolean contains (IBox other) { IVector3 omin = other.minimumExtent(), omax = other.maximumExtent(); return omin.x() >= _minExtent.x && omax.x() <= _maxExtent.x && omin.y() >= _minExtent.y && omax.y() <= _maxExtent.y && omin.z() >= _minExtent.z && omax.z() <= _maxExtent.z; }
@Override // from IMatrix4 public Vector3 projectPoint (IVector3 point, Vector3 result) { float px = point.x(), py = point.y(), pz = point.z(); float rw = 1f / (m03*px + m13*py + m23*pz + m33); return result.set((m00*px + m10*py + m20*pz + m30) * rw, (m01*px + m11*py + m21*pz + m31) * rw, (m02*px + m12*py + m22*pz + m32) * rw); }
/** * 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()); }
/** * Sets this to a scale matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToScale (IVector3 scale) { return setToScale(scale.x(), scale.y(), scale.z()); }
/** * Sets this to a rotation matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToRotation (float angle, IVector3 axis) { return setToRotation(angle, axis.x(), axis.y(), axis.z()); }
@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); }
/** * Sets this to a matrix that first scales, then rotates, then translates. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToTransform (IVector3 translation, IQuaternion rotation, float scale) { return setToRotation(rotation).set( m00 * scale, m10 * scale, m20 * scale, translation.x(), m01 * scale, m11 * scale, m21 * scale, translation.y(), m02 * scale, m12 * scale, m22 * scale, translation.z(), 0f, 0f, 0f, 1f); }
@Override // from IBox public boolean intersects (IRay3 ray) { IVector3 dir = ray.direction(); return Math.abs(dir.x()) > MathUtil.EPSILON && (intersectsX(ray, _minExtent.x) || intersectsX(ray, _maxExtent.x)) || Math.abs(dir.y()) > MathUtil.EPSILON && (intersectsY(ray, _minExtent.y) || intersectsY(ray, _maxExtent.y)) || Math.abs(dir.z()) > MathUtil.EPSILON && (intersectsZ(ray, _minExtent.z) || intersectsZ(ray, _maxExtent.z)); }