summaryrefslogtreecommitdiff
path: root/src/main/scala/sims/util/Positioning.scala
blob: 84441de8a74c3d55339e979cbd16d711707e208f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * Simple Mechanics Simulator (SiMS)
 * copyright (c) 2009 Jakob Odersky
 * made available under the MIT License
*/

package sims.util

import scala.language.implicitConversions

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
  }
}