Exemple #1
0
        public static VVector2D Rotation(VVector2D v1, float angle)
        {
            double theta = angle * Math.PI / 180;

            return(new VVector2D((float)(v1.X * Math.Cos(theta) - v1.Y * Math.Sin(theta)), (float)(v1.X * Math.Sin(theta) + v1.Y * Math.Cos(theta))));
            //(a_1  cos 𝜃−a_2  sin 𝜃, a_1  sin 𝜃+a_2  cos 𝜃);
        }
Exemple #2
0
        public static float operatorscale(VVector2D v1)
        {
            float mathsqrt;

            mathsqrt = (float)Math.Sqrt((Math.Pow(v1.X, 2) + Math.Pow(v1.Y, 2)));
            return(mathsqrt);
        }
Exemple #3
0
        public static VVector2D normalize(VVector2D v1)
        {
            float mathsqrt;

            mathsqrt = (float)Math.Sqrt((Math.Pow(v1.X, 2) + Math.Pow(v1.Y, 2)));

            return(new VVector2D(v1.X / mathsqrt, v1.Y / mathsqrt));
        }
Exemple #4
0
        public static double Dot(VVector2D v1, VVector2D v2)
        {
            //if(dot>360)
            //{
            //    throw new DivideByZeroException();
            //}
            double innersum = v1.X * v2.X + v1.Y * v2.Y;
            double vLength  = operatorscale(v1) * operatorscale(v2);
            double theta    = innersum / vLength;
            double innerD   = (double)(Math.Acos(theta) * (180 / Math.PI));


            return(innerD);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            VVector2D v1 = new VVector2D(5f, 7f);
            VVector2D v2 = new VVector2D(0f, 1f);
            VVector2D v3 = new VVector2D(1f, 1f);

            //  v1.Disp();
            //  v2.Disp();
            //  v3.Disp();
            //   VVector2D.vectorCopy();
            //    v1.innerVector()
            Console.WriteLine($"두벡터의내적{VVector2D.innerVector(v1,v2)}");
            Console.WriteLine($"두벡터의코사인{VVector2D.cosDot(v1, v2)}");
            Console.WriteLine($"두벡터의각{VVector2D.Dot(v1, v2)}");
            VVector2D.Rotation(v1, 135);
            v1.Disp();

            Console.WriteLine($"회전시킨벡터{VVector2D.Rotation(v1,135)}");
        }
Exemple #6
0
 public static VVector2D vectorCopy(VVector2D v1)//,VVector2D v2)
 {
     //  v1.X = v2.X;
     // v1.Y = v2.Y;
     return(new VVector2D(v1.X, v1.Y));
 }
Exemple #7
0
 public static VVector2D Ysymmetry(VVector2D v1)
 {
     return(new VVector2D(v1.X * -1, v1.Y));
 }
Exemple #8
0
 public static VVector2D Xsymmetry(VVector2D v1)
 {
     return(new VVector2D(v1.X, v1.Y * -1));
 }