If you think the Android project Resonos-Android-Framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.resonos.apps.library.model;
//www.java2s.comimport android.util.FloatMath;
/**
* A simple Point class that gives write access to the ImmutableCoord class.
* So simply cast any Coord object to an ImmutableCoord object to put in read-only mode.
* @author Chris Newhouse
* @see com.resonos.apps.library.model.ImmutableCoord
*/publicclass Coord extends ImmutableCoord {
public Coord() {
super();
}
public Coord(float x, float y) {
super(x, y);
}
public Coord(ImmutableCoord c) {
super(c);
}
public Coord set(float x, float y) {
this.x = x;
this.y = y;
returnthis;
}
public Coord set(ImmutableCoord c) {
this.x = c.x;
this.y = c.y;
returnthis;
}
public Coord add(ImmutableCoord c) {
this.x += c.x;
this.y += c.y;
returnthis;
}
public Coord sub(ImmutableCoord c) {
this.x -= c.x;
this.y -= c.y;
returnthis;
}
public Coord mult(float f) {
this.x *= f;
this.y *= f;
returnthis;
}
public Coord add(float f, float g) {
this.x += f;
this.y += g;
returnthis;
}
public Coord sub(float f, float g) {
this.x -= f;
this.y -= g;
returnthis;
}
/**
* Rotates this point around another point.
* @param origin : the coordinate to rotate around
* @param t : the angle in radians to rotate
* @return The same Coord, available for chaining.
*/public Coord rotateAround(ImmutableCoord origin, float t) {
// Rotates a point angle t around another point.
float ax = this.x - origin.x;
float ay = this.y - origin.y;
float nx = ax * FloatMath.cos(t) - ay * FloatMath.sin(t);
float ny = ax * FloatMath.sin(t) + ay * FloatMath.cos(t);
return set(nx + origin.x, ny + origin.y);
}
}