diff options
Diffstat (limited to 'src/main/scala/sims/util/Positioning.scala')
-rw-r--r-- | src/main/scala/sims/util/Positioning.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/scala/sims/util/Positioning.scala b/src/main/scala/sims/util/Positioning.scala new file mode 100644 index 0000000..cf72276 --- /dev/null +++ b/src/main/scala/sims/util/Positioning.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._ + +/**Utility functions for comfortable positioning of bodies.*/ +object Positioning { + + implicit def int2RelativeVector(x: Int): RelativeVector = new RelativeVector(x, 0) + implicit def double2RelativeVector(x: Double): RelativeVector = new RelativeVector(x, 0) + implicit def vector2RelativeVector(v: Vector2D): RelativeVector = new RelativeVector(v.x, v.y) + implicit def polar2Carthesian(p: Polar): Vector2D = p.toCarthesian + implicit def polar2RelativeVector(p: Polar): RelativeVector = vector2RelativeVector(p.toCarthesian) + + def position(s: Shape)(a: Vector2D) = { + s.pos = a + } +} |