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
.collision
28 * This is the result of a collision test between two shapes.
29 * A test result has the following attributes:
30 * * t: The time of impact. This is a value between 0.0 (beginning of the movement) and 1.0 (end of the
32 * * contact: The point of contact between the two shapes.
33 * * normal: The first shape's surface normal at the point of contact.
36 case class TestResult(t
: Double
, contact
: Vec2D
, normal
: Vec2D
) {
37 // Check if t is valid.
38 if (t
< 0.0 || t
> 1.0)
39 throw new IllegalArgumentException("The time must be between 0.0 and 1.0 (t: " + t
+ ").")
41 // Check if contact is valid.
43 throw new NullPointerException("Contact point must not be null.")
45 // Check if normal is valid.
47 throw new NullPointerException("Normal must not be null.")
49 throw new IllegalArgumentException("Normal must be a unit vector (normal: " + normal
+ ").")