//
import java.awt.*;

public class Vec
{
//----- VECTOR MATH -----

   public static void normalize(double[] v) {
      double s = norm(v);
      for (int i = 0 ; i < v.length ; i++)
         v[i] /= s;
   }

   public static double norm(double[] v) {
      return Math.sqrt(dot(v,v));
   }

   public static double dot(double[] a, double[] b) {
      double sum = 0;
      for (int i = 0 ; i < b.length ; i++)
         sum += a[i] * b[i];
      return sum;
   }

   public static void cross(double[] a, double[] b, double[] dst) {
      dst[0] = b[1] * a[2] - b[2] * a[1];
      dst[1] = b[2] * a[0] - b[0] * a[2];
      dst[2] = b[0] * a[1] - b[1] * a[0];
   }

   public static void copy(double[] src, double[] dst) {
      for (int i = 0 ; i < src.length ; i++)
         dst[i] = src[i];
   }
}