Contact: Contacts are now represented by two different contact objects, each viewing...
[scd.git] / src / net / habraun / sd / Collision.scala
blob6ad84e6e9414753ff728d25ea1c6c413507cb886
1 /*
2 Copyright (c) 2009 Hanno Braun <hanno@habraun.net>
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
19 package net.habraun.sd
23 /**
24 * Models a collision between two bodies.
25 * A collision has the following attributes:
26 * * t: The time of impact, relative to the timeframe that was inspected by the collision solver. A value of
27 * 0.0 means, the collision took place at the beginning of the time frame, 1.0 means at the end. A value
28 * of 0.5 would means, that the collision occured halfway through timeframe.
29 * * contact1, contact2: The contact objects that represent the collision from the viewpoint of each of the
30 * colliding bodies.
33 case class Collision(t: Double, contact1: Contact, contact2: Contact) {
34 if (t < 0.0 || t > 1.0) throw new IllegalArgumentException("Time of impact must be between 0.0 and 1.0.")
35 if (contact1 == null || contact2 == null) throw new NullPointerException("Contact must not be null.")