コード例 #1
0
ファイル: Triangle.cs プロジェクト: pim103/MathHullAndCompany
        public Triangle(Point p1, Point p2, Point p3)
        {
            Vector3 firstVector  = p2.GetPosition() - p1.GetPosition();
            Vector3 secondVector = p3.GetPosition() - p1.GetPosition();

            float det = firstVector.x * secondVector.y - firstVector.y * secondVector.x;

            Point temp;

            if (det < 0)
            {
                temp = p2;
                p2   = p3;
                p3   = temp;
            }

            // Barycenter
            Vector3 intercenter = Vector3.zero;

            intercenter.x = (p1.GetPosition().x + p2.GetPosition().x + p3.GetPosition().x) / 3;
            intercenter.y = (p1.GetPosition().y + p2.GetPosition().y + p3.GetPosition().y) / 3;
            intercenter.z = (p1.GetPosition().z + p2.GetPosition().z + p3.GetPosition().z) / 3;
            interCenter   = new Point(intercenter);

            this.p1 = p1;
            this.p2 = p2;
            this.p3 = p3;

            isActive = true;
            center   = new Point(CalculCircleCenter(p1.GetPosition(), p2.GetPosition(), p3.GetPosition()));

            normale = GetNormal();
        }
コード例 #2
0
ファイル: Triangle.cs プロジェクト: pim103/MathHullAndCompany
        public Triangle(Point p1, Point p2, Point p3, Point centerPoint)
        {
            this.p1 = p1;
            this.p2 = p2;
            this.p3 = p3;

            // Barycenter
            Vector3 intercenter = Vector3.zero;

            intercenter.x = (p1.GetPosition().x + p2.GetPosition().x + p3.GetPosition().x) / 3;
            intercenter.y = (p1.GetPosition().y + p2.GetPosition().y + p3.GetPosition().y) / 3;
            intercenter.z = (p1.GetPosition().z + p2.GetPosition().z + p3.GetPosition().z) / 3;
            interCenter   = new Point(intercenter);

            isActive = true;
            center   = new Point(CalculCircleCenter(p1.GetPosition(), p2.GetPosition(), p3.GetPosition()));
            normale  = GetNormal();

            if (Vector3.Dot(normale, (this.p1.GetPosition() - centerPoint.GetPosition())) < 0)
            {
                normaleInversed = true;
                normale        *= -1;
            }
        }
コード例 #3
0
        public Vector3 GetNormal()
        {
            Vector3 normalised = (p2.GetPosition() - p1.GetPosition()).normalized;

            Vector3 normal = Vector3.zero;

            normal.x = normalised.y;
            normal.y = -normalised.x;

            return(normal);
        }
コード例 #4
0
ファイル: Triangle.cs プロジェクト: pim103/MathHullAndCompany
 private Vector3 GetNormal()
 {
     return(Vector3.Cross(p2.GetPosition() - p1.GetPosition(), p3.GetPosition() - p1.GetPosition()).normalized);
 }