public abstract class Transformer extends Transformed implements Parameter {
	Vector3D curr_ = new Vector3D();
	Matrix3D mat_ = new Matrix3D(),
		tot_ = new Matrix3D(); 
    protected final double EPS=0.0001;
	Transformer() {
		mat_.identity(); // should correspond to zeroed curr_
	}
    Transformer(Transformed child) {
        super(child);
        mat_.identity();
    }    
    public Matrix3D getFrame() {
        return tot_;
    }
        
	boolean differs(Vector3D value) {	
        return Math.abs(curr_.x()-value.x())>EPS 
			|| Math.abs(curr_.y()-value.y())>EPS 
			|| Math.abs(curr_.z()-value.z())>EPS;
	}
	//Parameter
	public void change(Vector3D value) {
		if(differs(value)) {
			recalc(value);
			curr_.copy(value);
		}
	}
    public void get(Vector3D ret) {
        ret.copy(curr_);
    }
	abstract void recalc(Vector3D value);
    abstract String id();
	//Transformed
	public void transform(Matrix3D parent) {
		parent.multiply(mat_,tot_);
        //System.out.println("xfrmr xfor "+id()+" mat "+mat_);
        //System.out.println("xfrmr xfor "+id()+" tot "+tot_);
        if(children_!=null) 
            for(int i = 0; i<children_.length; ++i)
                if(children_[i]!=null)
                    children_[i].transform(tot_);
	}
}
