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
28 * Models a contact of one body to another.
29 * A contact has the following attributes:
30 * * b: The body that has contact to another.
31 * * point: The position vector of the point of contact.
32 * * normal: The surface normal of b at the point of contact. This is a unit vector.
33 * * other: The other body that b has contact to.
36 case class Contact(b
: Body
, point
: Vec2D
, normal
: Vec2D
, other
: Body
) {
37 // Make sure the parameters are not null.
38 if (b
== null || point
== null || normal
== null || other
== null)
39 throw new NullPointerException
41 // Check if vectors are unit vectors.
42 if (normal
.squaredLength
< 0.95 || normal
.squaredLength
> 1.05)
43 throw new IllegalArgumentException("Normal must be a unit vectors (normal: " + normal
+ ").")