Beispiel #1
0
        static void Main(string[] args)
        {
            // создание членов класса
            vect A = new vect(5);
            vect B = new vect(10);
            vect D = new vect(15);

            // ввод данных векторов в массивы
            A.vv("A");
            B.vv("B");
            D.vv("D");
            // ввод данных векторов из массива
            A.vyv("A");
            B.vyv("B");
            D.vyv("D");
            // Поиск и вывод минимальных элементов в векторах
            A.FindMax("A");
            A.FindMin("A");

            B.FindMax("B");
            B.FindMin("B");

            B.FindMax("D");
            B.FindMin("D");
            Console.ReadKey();
        }
Beispiel #2
0
        void InitAngleConfig(Animator anim, Segment segment, float inhaleAngle, float exhaleAngle)
        {
            var btra = anim.GetBoneTransform(segment.Bone);

            var forwardDot = Vector3.Dot(transform.right, transform.InverseTransformDirection(btra.forward));
            var rightDot   = Vector3.Dot(transform.right, transform.InverseTransformDirection(btra.right));
            var upDot      = Vector3.Dot(transform.right, transform.InverseTransformDirection(btra.up));

            //Debug.Log("---- " + this.gameObject.name + " (" + btra.gameObject.name + ")");
            //Debug.Log("Forward Dot:" + forwardDot);
            //Debug.Log("Right   Dot:" + rightDot);
            //Debug.Log("Up      Dot:" + upDot);

            float min     = 1;
            vect  bestvec = 0;
            float machv;

            machv = 1 - Mathf.Abs(forwardDot);
            if (machv < min)
            {
                bestvec = vect.forward;
                min     = machv;
            }

            machv = 1 - Mathf.Abs(rightDot);
            if (machv < min)
            {
                bestvec = vect.right;
                min     = machv;
            }

            machv = 1 - Mathf.Abs(upDot);
            if (machv < min)
            {
                bestvec = vect.up;
                min     = machv;
            }

            switch (bestvec)
            {
            case vect.forward:
                segment.z.max         = inhaleAngle * Mathf.Sign(forwardDot);
                segment.z.min         = exhaleAngle * Mathf.Sign(forwardDot);
                segment.z.maxDuration = this.maxDuration;
                segment.z.minDuration = this.minDuration;
                break;

            case vect.right:
                segment.x.max         = inhaleAngle * Mathf.Sign(rightDot);
                segment.x.min         = exhaleAngle * Mathf.Sign(rightDot);
                segment.x.maxDuration = this.maxDuration;
                segment.x.minDuration = this.minDuration;
                break;

            case vect.up:
                segment.y.max         = inhaleAngle * Mathf.Sign(upDot);
                segment.y.min         = exhaleAngle * Mathf.Sign(upDot);
                segment.y.maxDuration = this.maxDuration;
                segment.y.minDuration = this.minDuration;
                break;
            }
        }