예제 #1
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
        private double cuclulateAngle(Vectorchick vectorchick1, Vectorchick vectorchick2)
        {
            double lengthVector1        = culculateVector(vectorchick1);
            double lengthVector2        = culculateVector(vectorchick2);
            double scalarЬultiplication = vectorchick1.x * vectorchick2.x + vectorchick1.y * vectorchick2.y;

            return(Math.Acos(scalarЬultiplication / (lengthVector1 * lengthVector2)));
        }
예제 #2
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
            public static Vectorchick operator +(Vectorchick a, Vectorchick b)
            {
                Vectorchick c = new Vectorchick();

                c.x = a.x + b.x;
                c.y = a.y + b.y;
                return(c);
            }
예제 #3
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
            public static Vectorchick operator *(Vectorchick a, double b)
            {
                Vectorchick c = new Vectorchick();

                c.x = a.x * b;
                c.y = a.y * b;
                return(c);
            }
예제 #4
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
        private void ballColision(int i, int j)
        {
            Vectorchick centerVector = new Vectorchick();

            centerVector.x = listBall[j].Cordinates.x - listBall[i].Cordinates.x;
            centerVector.y = listBall[j].Cordinates.y - listBall[i].Cordinates.y;

            double AngleI             = cuclulateAngle(centerVector, listBall[i].speed);
            double AngleJ             = cuclulateAngle(centerVector, listBall[j].speed);
            double lengthCenterVector = culculateVector(centerVector);

            centerVector.x /= lengthCenterVector;
            centerVector.y /= lengthCenterVector;
            Vectorchick swapVectorI = new Vectorchick();
            Vectorchick swapVectorJ = new Vectorchick();

            swapVectorI       = centerVector * culculateVector(listBall[i].speed) * Math.Cos(AngleI);
            swapVectorJ       = centerVector * culculateVector(listBall[j].speed) * Math.Cos(AngleJ);
            listBall[i].speed = listBall[i].speed - swapVectorI + swapVectorJ;
            listBall[j].speed = listBall[j].speed - swapVectorJ + swapVectorI;
        }
예제 #5
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
 private double culculateVector(Vectorchick vectorchick1)
 {
     return(Math.Sqrt(Math.Pow(vectorchick1.x, 2) + Math.Pow(vectorchick1.y, 2)));
 }
예제 #6
0
파일: Form1.cs 프로젝트: BunnyBoss75/Labs
 public Ball()
 {
     Cordinates = new Point();
     topLeft    = new Point();
     speed      = new Vectorchick();
 }