11package vecmatlib .matrix
22
3- import vecmatlib .vector .{Vec3d , Vec4d }
3+ import vecmatlib .vector .{Vec2d , Vec3d , Vec4d }
44
55/**
66 * 4x4 double matrix.
@@ -239,6 +239,15 @@ object Mat4d {
239239 0.0 , 0.0 , 0.0 , 1.0
240240 )
241241
242+ /**
243+ * Returns a 4x4 translation matrix with the given translation on the x and y axes.
244+ *
245+ * @param x X component of the translation
246+ * @param y Y component of the translation
247+ * @return A 4x4 translation matrix
248+ */
249+ def translation (x : Double , y : Double ): Mat4d = translation(x, y, 0.0 )
250+
242251 /**
243252 * Returns a 4x4 translation matrix with the given translation.
244253 *
@@ -247,6 +256,14 @@ object Mat4d {
247256 */
248257 def translation (v : Vec3d ): Mat4d = translation(v.x, v.y, v.z)
249258
259+ /**
260+ * Returns a 4x4 translation matrix with the given translation on the x and y axes.
261+ *
262+ * @param v The translation vector
263+ * @return A 4x4 translation matrix
264+ */
265+ def translation (v : Vec2d ): Mat4d = translation(v.x, v.y)
266+
250267 /**
251268 * Returns a 4x4 rotation matrix with the given rotation on the x axis.
252269 *
@@ -319,11 +336,36 @@ object Mat4d {
319336 0.0 , 0.0 , 0.0 , 1.0
320337 )
321338
339+ /**
340+ * Returns a 4x4 scaling matrix with the given scale on all three axes.
341+ *
342+ * @param scale Scale on all three axes
343+ * @return A 4x4 scaling matrix
344+ */
345+ def scaling (scale : Double ): Mat4d = scaling(scale, scale, scale)
346+
347+ /**
348+ * Returns a 4x4 scaling matrix with the given scale on the x and y axes and a scale of 1 on the z axis.
349+ *
350+ * @param x Scale on the x axis
351+ * @param y Scale on the y axis
352+ * @return A 4x4 scaling matrix
353+ */
354+ def scaling (x : Double , y : Double ): Mat4d = scaling(x, y, 1.0 )
355+
322356 /**
323357 * Returns a 4x4 scaling matrix with the given scale.
324358 *
325359 * @param v The scale vector
326360 * @return A 4x4 scaling matrix
327361 */
328362 def scaling (v : Vec3d ): Mat4d = scaling(v.x, v.y, v.z)
363+
364+ /**
365+ * Returns a 4x4 scaling matrix with the given scale on the x and y axes and a scale of 1 on the z axis.
366+ *
367+ * @param v The scale vector
368+ * @return A 4x4 scaling matrix
369+ */
370+ def scaling (v : Vec2d ): Mat4d = scaling(v.x, v.y)
329371}
0 commit comments