using UnityEngine;
using System.Collections;

public class SineRotation : MonoBehaviour {

	public enum Axis{none,x,y,z};
	public Axis axis1 = Axis.x;
	public Axis axis2 = Axis.z;
	public float amplitude1 = .5f;
	public float amplitude2 = .5f;
	public float rotationPerSecond = 1f;
	public float phase1=0f;
	public float phase2 = 0f;

	// Update is called once per frame
	void Update () {
		Quaternion q = transform.localRotation;
		if(axis1!=Axis.none){
			phase1+=Mathf.PI*2*rotationPerSecond*Time.deltaTime;
			float n = Mathf.Sin (phase1)*amplitude1;
			if(axis1==Axis.x)q.x = n;
			else if(axis1==Axis.y)q.y = n;
			else if(axis1==Axis.z)q.z = n;
		}
		if(axis2!=Axis.none){
			phase2+=Mathf.PI*2*rotationPerSecond*Time.deltaTime;
			float n = Mathf.Cos (phase2)*amplitude2;
			if(axis2==Axis.x)q.x = n;
			else if(axis2==Axis.y)q.y = n;
			else if(axis2==Axis.z)q.z = n;
		}
		transform.localRotation = q;
	}
}
