Ejemplo n.º 1
0
        //点p1 ,p2 ,targetで構成される三角形で、traget点での角度が鈍角か判定
        public static bool isObtuseAngle(LDPoint p1, LDPoint p2, LDPoint target)
        {
            LDVector2 a = new LDVector2(p1);
            LDVector2 b = new LDVector2(p2);
            LDVector2 c = new LDVector2(target);


            LDVector2 ab = a - b;
            LDVector2 bc = b - c;
            LDVector2 ca = c - a;

            if (LDVector2.dotProduct(bc, ca) < 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        //点p1 ,p2 ,p3 で構成される三角形が鈍角三角形か判定する
        public static bool isObtuseTriangle(LDPoint p1, LDPoint p2, LDPoint p3)
        {
            LDVector2 __a = new LDVector2(p1);
            LDVector2 __b = new LDVector2(p2);
            LDVector2 __c = new LDVector2(p3);


            LDVector2 _a = __a - __b;
            LDVector2 _b = __b - __c;
            LDVector2 _c = __c - __a;

            //良く考えたら三角形全部の角度調べるだけでよかった。
            if (LDVector2.dotProduct(_a, _b) < 0)
            {
                return(true);
            }
            if (LDVector2.dotProduct(_a, _c) < 0)
            {
                return(true);
            }
            if (LDVector2.dotProduct(_b, _c) < 0)
            {
                return(true);
            }

            return(false);

            //	float a=_a.length();
            //	float b=_b.length();
            //	float c=_c.length();
            //	int longestIndex;
            //	if ( a>=b  && a >=c )
            //	{
            //		longestIndex=0;
            //	}
            //	else if ( b >=a &&b >=c )
            //	{
            //		longestIndex=1;
            //	}
            //	else
            //	{
            //		longestIndex=2;
            //	}

            //	if ( longestIndex==0 )
            //	{
            //		if ( a*a<=b*b+c*c )
            //		{
            //			return false;
            //		}
            //		return true;
            //	}
            //	if ( longestIndex==1 )
            //	{
            //		if ( b*b<=a*a+c*c )
            //		{
            //			return false;
            //		}
            //		return true;
            //	}
            //	if ( longestIndex==2 )
            //	{
            //		if ( c*c<=b*b+a*a )
            //		{
            //			return false;
            //		}
            //		return true;
            //	}
            //	//ここまでのどこかに引っかかるはず 引っかからなかったらこの関数のどこかにバグがあるはず
            //	Debug.Assert( !" error" );
            //	return false;
        }