/** * Constructs a transformation matrix that transform from a local to a * global reference system with the specified origin and orthonormal axes * of the local system. * * @param origin the origin of the local reference system * @param axes the orthonormal axes of the local reference system * * @return the transformation matrix that transforms from the local to the * global reference system */ public static Matrix fromLocalOrientation(Vec4 origin, Vec4[] axes) { return Matrix.fromTranslation(origin).multiply(TransformationMatrix.fromAxes(axes)); }
public final Matrix negate() { return new Matrix( 0.0 - this.m11, 0.0 - this.m12, 0.0 - this.m13, 0.0 - this.m14, 0.0 - this.m21, 0.0 - this.m22, 0.0 - this.m23, 0.0 - this.m24, 0.0 - this.m31, 0.0 - this.m32, 0.0 - this.m33, 0.0 - this.m34, 0.0 - this.m41, 0.0 - this.m42, 0.0 - this.m43, 0.0 - this.m44, // Negative of orthonormal 3D transformHACK matrix is also an orthonormal 3D transformHACK. this.isOrthonormalTransform); }
public final Matrix getInverse() { if (this.isOrthonormalTransform) return computeTransformInverse(this); else return computeGeneralInverse(this); }
public final Matrix divideComponents(double value) { if (isZero(value)) { throw new IllegalArgumentException("Argument Out Of Range"); } return new Matrix( this.m11 / value, this.m12 / value, this.m13 / value, this.m14 / value, this.m21 / value, this.m22 / value, this.m23 / value, this.m24 / value, this.m31 / value, this.m32 / value, this.m33 / value, this.m34 / value, this.m41 / value, this.m42 / value, this.m43 / value, this.m44 / value); }
u = u.normalize3(); Matrix mAxes = new Matrix( s.x, s.y, s.z, 0.0, u.x, u.y, u.z, 0.0, 0.0, 0.0, 0.0, 1.0, true); Matrix mEye = Matrix.fromTranslation( -eye.x, -eye.y, -eye.z); return mAxes.multiply(mEye);
return fromTranslation(origin).multiply(fromAxes(axes));
/** * Compute the intersection of three planes. * * @param pa the first plane. * @param pb the second plane. * @param pc the third plane. * * @return the Cartesian coordinates of the intersection, or null if the three planes to not intersect at a point. * * @throws IllegalArgumentException if any of the planes are null. */ public static Vec4 intersect(Plane pa, Plane pb, Plane pc) { if (pa == null || pb == null || pc == null) { throw new IllegalArgumentException("Plane Is Null"); } Vec4 na = pa.getNormal(); Vec4 nb = pb.getNormal(); Vec4 nc = pc.getNormal(); Matrix m = new Matrix( na.x, na.y, na.z, 0, nb.x, nb.y, nb.z, 0, nc.x, nc.y, nc.z, 0, 0, 0, 0, 1, true ); Matrix mInverse = m.getInverse(); Vec4 D = new Vec4(-pa.getDistance(), -pb.getDistance(), -pc.getDistance()); return D.transformBy3(mInverse); }
public static Matrix fromTranslation(Vec4 translation) { if (translation == null) { throw new IllegalArgumentException("Vec4 Is Null"); } return fromTranslation(translation.x, translation.y, translation.z); }
/** * Constructs a transformation matrix that transform from a global to a * local reference system with the specified origin and orthonormal axes * of the local system. * * @param origin the origin of the local reference system * @param axes the orthonormal axes of the local reference system * * @return the transformation matrix that transforms from the global to the * local reference system */ public static Matrix toLocalOrientation(Vec4 origin, Vec4[] axes) { return TransformationMatrix.fromLocalOrientation(origin, axes).getInverse(); }
public static Matrix fromAxisAngle(Angle angle, double axisX, double axisY, double axisZ) { if (angle == null) { throw new IllegalArgumentException("Angle Is Null"); } return fromAxisAngle(angle, axisX, axisY, axisZ, true); }
public static Matrix fromScale(double scale) { return fromScale(scale, scale, scale); }
public static Matrix fromQuaternion(Quaternion quaternion) { if (quaternion == null) { throw new IllegalArgumentException("Quaternion Is Null"); } return fromQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w, true); }
u = u.normalize3(); Matrix mAxes = new Matrix( s.x, u.x, f.x, 0.0, s.y, u.y, f.y, 0.0, 0.0, 0.0, 0.0, 1.0, true); Matrix mEye = Matrix.fromTranslation( eye.x, eye.y, eye.z); return mEye.multiply(mAxes);
public static Matrix fromAxisAngle(Angle angle, Vec4 axis) { if (angle == null) { throw new IllegalArgumentException("Angle Is Null"); } if (axis == null) { throw new IllegalArgumentException("Vec4 Is Null"); } return fromAxisAngle(angle, axis.x, axis.y, axis.z, true); }
public static Matrix fromScale(Vec4 scale) { if (scale == null) { throw new IllegalArgumentException("Vec4 Is Null"); } return fromScale(scale.x, scale.y, scale.z); }
public static Matrix fromScale(double scaleX, double scaleY, double scaleZ) { return new Matrix( scaleX, 0.0, 0.0, 0.0, 0.0, scaleY, 0.0, 0.0, 0.0, 0.0, scaleZ, 0.0, 0.0, 0.0, 0.0, 1.0, // Scale matrices are non-orthogonal, 3D transforms. false); }
public static Matrix fromTranslation(double x, double y, double z) { return new Matrix( 1.0, 0.0, 0.0, x, 0.0, 1.0, 0.0, y, 0.0, 0.0, 1.0, z, 0.0, 0.0, 0.0, 1.0, // Translation matrices are orthogonal, 3D transforms. true); }