package com.roiron.spaceproject.physic;

import com.roiron.spaceproject.graphic.GraphicObject;

class PhysicUtility {
		public static double[] toPolar(double[] vect)
		{
			double radius=Math.sqrt(Math.pow(vect[0], 2)+Math.pow(vect[1], 2));
			double theta = Math.atan2(vect[1], vect[0]);
			return new double[]{radius,theta};
		}
		public static double[] toCarthe(double[] vect)
		{
			double x=vect[0]*Math.cos(vect[1]);
			double y = vect[0]*Math.sin(vect[1]);
			return new double[]{x,y};
		}
		public static double[][] toGlobalPolar(double[][] globalState)
		{
			return new double[][]{toPolar(globalState[0]),toPolar(globalState[1])};
		}
		public static double[][] toGlobalCarther(double[][] globalState)
		{
			return new double[][]{toCarthe(globalState[0]),toCarthe(globalState[1])};
		}

}
		

@@ -111,16 +111,260 @@
 ility %7B%0A
+%09/**%0A%09 * Transform the absolute coordinate to a polar one in the reference system%0A%09 * @param vect state vector we want to convert%0A%09 * @param ref reference system where we want to be%0A%09 * @return the polar coordinate in the reference system%0A%09 */%0A
 %09%09public
@@ -393,32 +393,46 @@
 ar(double%5B%5D vect
+, double%5B%5D ref
 )%0A%09%09%7B%0A%09%09%09double 
@@ -464,16 +464,23 @@
 (vect%5B0%5D
+-ref%5B0%5D
 , 2)+Mat
@@ -492,16 +492,23 @@
 (vect%5B1%5D
+-ref%5B1%5D
 , 2));%0A%09
@@ -546,14 +546,28 @@
 t%5B1%5D
-, vect
+-ref%5B1%5D, vect%5B0%5D-ref
 %5B0%5D)
@@ -657,16 +657,29 @@
 e%5B%5D vect
+,double%5B%5D ref
 )%0A%09%09%7B%0A%09%09
@@ -708,25 +708,39 @@
 .cos(vect%5B1%5D
-)
++ref%5B1%5D)+ref%5B0%5D
 ;%0A%09%09%09double 
@@ -767,17 +767,31 @@
 (vect%5B1%5D
-)
++ref%5B1%5D)+ref%5B0%5D
 ;%0A%09%09%09ret
@@ -872,32 +872,54 @@
 %5B%5D%5B%5D globalState
+, double%5B%5D%5B%5D reference
 )%0A%09%09%7B%0A%09%09%09return 
@@ -955,18 +955,36 @@
 State%5B0%5D
-)
 ,
+reference%5B0%5D),%0A%09%09%09%09
 toPolar(
@@ -989,32 +989,45 @@
 r(globalState%5B1%5D
+,reference%5B1%5D
 )%7D;%0A%09%09%7D%0A%09%09public
@@ -1083,16 +1083,37 @@
 balState
+,double%5B%5D%5B%5D reference
 )%0A%09%09%7B%0A%09%09
@@ -1158,18 +1158,36 @@
 State%5B0%5D
-)
 ,
+reference%5B0%5D),%0A%09%09%09%09
 toCarthe
@@ -1197,24 +1197,37 @@
 obalState%5B1%5D
+,reference%5B1%5D
 )%7D;%0A%09%09%7D%0A%0A%7D%0A%09

add reference