From 01c5c700647feba596e02cb7a2e672f5301504ff Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Mon, 29 Jun 2015 12:32:00 +0200 Subject: Port to scala 2.11 --- src/main/scala/sims/util/RelativeVector.scala | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/scala/sims/util/RelativeVector.scala (limited to 'src/main/scala/sims/util/RelativeVector.scala') diff --git a/src/main/scala/sims/util/RelativeVector.scala b/src/main/scala/sims/util/RelativeVector.scala new file mode 100644 index 0000000..374f92c --- /dev/null +++ b/src/main/scala/sims/util/RelativeVector.scala @@ -0,0 +1,24 @@ +/* + * Simple Mechanics Simulator (SiMS) + * copyright (c) 2009 Jakob Odersky + * made available under the MIT License +*/ + +package sims.util + +import sims.geometry._ +import sims.dynamics._ + +class RelativeVector(val x: Double, val y: Double) { + def above(point: Vector2D): Vector2D = point + Vector2D(0, x) + def below(point: Vector2D): Vector2D = point - Vector2D(0, x) + def left(point: Vector2D): Vector2D = point - Vector2D(x, 0) + def right(point: Vector2D): Vector2D = point + Vector2D(x, 0) + def from(point: Vector2D): Vector2D = point + Vector2D(x, y) + + def above(s: Shape): Vector2D = this.above(s.pos) + def below(s: Shape): Vector2D = this.below(s.pos) + def left(s: Shape): Vector2D = this.left(s.pos) + def right(s: Shape): Vector2D = this.right(s.pos) + def from(s: Shape): Vector2D = this.from(s.pos) +} -- cgit v1.2.3