From cec7a2bc253865a848a8318bcc9beb4fea392e3f Mon Sep 17 00:00:00 2001 From: httpdigest Date: Sat, 20 Jun 2015 00:02:20 +0200 Subject: [PATCH] Add Matrix4f.reflect overloads with vector arguments --- src/org/joml/Matrix4f.java | 56 +++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/org/joml/Matrix4f.java b/src/org/joml/Matrix4f.java index 3a03dbafb..ff2ca8588 100644 --- a/src/org/joml/Matrix4f.java +++ b/src/org/joml/Matrix4f.java @@ -3475,6 +3475,30 @@ public Matrix4f reflect(float nx, float ny, float nz, float d) { * @return this */ public Matrix4f reflect(float nx, float ny, float nz, float px, float py, float pz) { + return reflect(nx, ny, nz, px, py, pz, this); + } + + /** + * Apply a mirror/reflection transformation to this matrix that reflects about the given plane + * specified via the plane normal and a point on the plane, and store the result in dest. + * + * @param nx + * the x-coordinate of the plane normal + * @param ny + * the y-coordinate of the plane normal + * @param nz + * the z-coordinate of the plane normal + * @param px + * the x-coordinate of a point on the plane + * @param py + * the y-coordinate of a point on the plane + * @param pz + * the z-coordinate of a point on the plane + * @param dest + * will hold the result + * @return this + */ + public Matrix4f reflect(float nx, float ny, float nz, float px, float py, float pz, Matrix4f dest) { // normalize the normal (just to be sure) float length = (float) Math.sqrt(nx * nx + ny * ny + nz * nz); float nnx = nx / length; @@ -3482,7 +3506,37 @@ public Matrix4f reflect(float nx, float ny, float nz, float px, float py, float float nnz = nz / length; // project (px, py, pz) to normal float dot = nnx * px + nny * py + nnz * pz; - return reflect(nx, ny, nz, -dot, this); + return reflect(nx, ny, nz, -dot, dest); + } + + /** + * Apply a mirror/reflection transformation to this matrix that reflects about the given plane + * specified via the plane normal and a point on the plane. + * + * @param normal + * the plane normal + * @param point + * a point on the plane + * @return this + */ + public Matrix4f reflect(Vector3f normal, Vector3f point) { + return reflect(normal.x, normal.y, normal.z, point.x, point.y, point.z); + } + + /** + * Apply a mirror/reflection transformation to this matrix that reflects about the given plane + * specified via the plane normal and a point on the plane, and store the result in dest. + * + * @param normal + * the plane normal + * @param point + * a point on the plane + * @param dest + * will hold the result + * @return this + */ + public Matrix4f reflect(Vector3f normal, Vector3f point, Matrix4f dest) { + return reflect(normal.x, normal.y, normal.z, point.x, point.y, point.z, dest); } /**