summaryrefslogtreecommitdiff
path: root/src/tesseract/forces/LinearOrigin.java
blob: ca4651d83b44016b26543fca248681d6429ee3f7 (plain)
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
package tesseract.forces;

import javax.vecmath.Vector3f;

import tesseract.objects.PhysicalObject;

@SuppressWarnings("restriction")
public class LinearOrigin extends Force {
	private float scale;
	
	public LinearOrigin(float scale) {
		this.scale = scale;
	}

	public Vector3f calculateForce(PhysicalObject obj) {
		Vector3f position = obj.getPosition();
		Vector3f force = new Vector3f(-position.x, -position.y, -position.z);
		force.scale(scale);
		return force;
	}
	
	public String toString() {
		return "Linear proportional force towards the origin";
	}
}