From a073e83ac295916df7ea2ae36d35b32396e2ce9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 6 Jun 2017 19:30:59 -0400 Subject: [PATCH] geometry: move up `Point3d::offset` from gamnit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/gamnit/flat.nit | 6 ------ lib/geometry/points_and_lines.nit | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/gamnit/flat.nit b/lib/gamnit/flat.nit index 6a52dc4..f7f7c4a 100644 --- a/lib/gamnit/flat.nit +++ b/lib/gamnit/flat.nit @@ -583,12 +583,6 @@ private class Simple2dProgram end redef class Point3d[N] - # Get a new `Point3d[Float]` with an offset of each axis of `x, y, z` - fun offset(x, y, z: Numeric): Point3d[Float] - do - return new Point3d[Float](self.x.to_f+x.to_f, self.y.to_f+y.to_f, self.z.to_f+z.to_f) - end - # --- # Associate each point to its sprites diff --git a/lib/geometry/points_and_lines.nit b/lib/geometry/points_and_lines.nit index 16efae0..22d2c51 100644 --- a/lib/geometry/points_and_lines.nit +++ b/lib/geometry/points_and_lines.nit @@ -142,6 +142,17 @@ interface IPoint3d[N: Numeric] var s = dist2_xy(other).add(dz.mul(dz)) return x.value_of(s) end + + # Get a new `Point3d[Float]` at an offset of `x, y, z` from `self` + # + # ~~~ + # var origin = new Point3d[Float](1.0, 1.0, 1.0) + # assert origin.offset(1.0, 2.0, 3.0).to_s == "(2.0, 3.0, 4.0)" + # ~~~ + fun offset(x, y, z: Numeric): Point3d[Float] + do return new Point3d[Float](self.x.to_f+x.to_f, + self.y.to_f+y.to_f, + self.z.to_f+z.to_f) end # 3D point with `x`, `y` and `z` -- 1.7.9.5