public class Complex { public float r,i; public Complex() { r = 0; i = 0; } public Complex(float lr,float li) { r = lr; i = li; } public Complex(Complex o) { r = o.r; i = o.i; } public void setMag(float m) { double tm = Math.sqrt(r*r+i*i); if (tm!=0) { r*=(m/tm); i*=(m/tm); } } public void rotPhase(float p) { double or = r*Math.cos(p) + i*Math.sin(p); i = (float)(-r*Math.sin(p) + i*Math.cos(p)); r = (float)or; } public float getPhase() { return (float)Math.atan2(i,r); } public float getMag() { return (float)Math.sqrt(i*i+r*r); } }