summaryrefslogtreecommitdiff
path: root/src/tesseract/forces/CircularXY.java
blob: cef632d133653e0ff88b39971b8767287cd652a9 (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
26
27
package tesseract.forces;

import javax.vecmath.Vector3f;

import tesseract.objects.PhysicalObject;

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

	public Vector3f calculateForce(final PhysicalObject obj) {
		Vector3f force = new Vector3f(-obj.getPosition().y, 0, obj.getPosition().x);
		if (force.length() > 0) {
			force.normalize();
			force.scale(strength);
		}
		return force;
	}
	
	public String toString() {
		return "Tangential force in the XY plane";
	}
}