예제 #1
0
 public void ConvertFromSherical()
 {
     try
     {//parse strings into floating point numbers
         float r = Single.Parse(spherical_inputs[0].text);
         if (r < 0)
         {
             throw new Exception("Only positive radii allowed!");
         }
         float azim  = Single.Parse(spherical_inputs[1].text) * (float)Math.PI / 180;
         float polar = Single.Parse(spherical_inputs[2].text) * (float)Math.PI / 180;
         vectSpherical = new MyVector3_Spherical(r, azim, polar);
     }
     catch (Exception e)
     {//parsing failed
         Debug.LogError(e.Message);
         spherical_inputs[0].text = "";
         spherical_inputs[1].text = "";
         spherical_inputs[2].text = "";
         return;
     }
     //print vectors to the scene
     vectCartesian   = vectSpherical.ToCartesian();
     vectCylindrical = vectSpherical.ToCylindrical();
     PrintVectors();
 }
예제 #2
0
 public void ConvertFromCartesian()
 {
     try
     {//parse strings into floating point numbers
         float x = Single.Parse(cartesian_inputs[0].text);
         float y = Single.Parse(cartesian_inputs[1].text);
         float z = Single.Parse(cartesian_inputs[2].text);
         vectCartesian = new MyVector3(x, y, z);
     }
     catch (Exception e)
     {//parsing failed
         Debug.LogError(e.Message);
         cartesian_inputs[0].text = "";
         cartesian_inputs[1].text = "";
         cartesian_inputs[2].text = "";
         return;
     }
     //print vectors to the scene
     vectCylindrical = vectCartesian.ToCylindrical();
     vectSpherical   = vectCartesian.ToSpherical();
     PrintVectors();
 }