Plane { public Plane transformByMatrix(Matrix4 matrix) { if (matrix == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Plane", "transformByMatrix", "missingMatrix")); } double[] m = matrix.m; double x = m[0] * this.normal.x + m[1] * this.normal.y + m[2] * this.normal.z + m[3] * this.distance; double y = m[4] * this.normal.x + m[5] * this.normal.y + m[6] * this.normal.z + m[7] * this.distance; double z = m[8] * this.normal.x + m[9] * this.normal.y + m[10] * this.normal.z + m[11] * this.distance; double distance = m[12] * this.normal.x + m[13] * this.normal.y + m[14] * this.normal.z + m[15] * this.distance; this.normal.x = x; this.normal.y = y; this.normal.z = z; this.distance = distance; this.normalizeIfNeeded(); return this; } Plane();  Plane(double x, double y, double z, double distance);  Plane(Plane plane); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); double distanceToPoint(Vec3 point); Plane set(double x, double y, double z, double distance); Plane set(Plane plane); Plane transformByMatrix(Matrix4 matrix); double dot(Vec3 vector); boolean intersectsSegment(Vec3 endPoint1, Vec3 endPoint2); int onSameSide(Vec3 pointA, Vec3 pointB); Vec3[] clip(Vec3 pointA, Vec3 pointB);  }
@Test public void testTransformByMatrix() throws Exception { Plane p = new Plane(0, 0, -1, 10); final double theta = 30.0; final double c = Math.cos(Math.toRadians(theta)); final double s = Math.sin(Math.toRadians(theta)); final double x = 0; final double y = 0; final double z = 3; Matrix4 m = new Matrix4(); m.multiplyByRotation(1, 0, 0, theta); m.multiplyByTranslation(x, y, z); m.invertOrthonormal().transpose(); p.transformByMatrix(m); assertEquals("normal x", p.normal.x, 0, 0); assertEquals("normal y", p.normal.y, s, 0); assertEquals("normal z", p.normal.z, -c, 0); assertEquals("distance", p.distance, 13.0, 0); }