示例#1
0
        public LDPoint inverseTransformOneMinusT(float x, float y)
        {
            //Cubismから移植。
            LDVector2 v0  = new LDVector2(new LDPoint(x, y) - m_p2);
            LDVector2 v1  = new LDVector2(m_p1 - m_p2);
            LDVector2 v2  = new LDVector2(m_p0 - m_p2);
            double    det = v1.x() * v2.y() - v1.y() * v2.x();

            double tx = (v2.y() * v0.x() - v2.x() * v0.y()) / det;
            double ty = (-v1.y() * v0.x() + v1.x() * v0.y()) / det;

            return(new LDPoint(1 - (float)tx, 1 - (float)ty));
        }
示例#2
0
        public LDPoint inverseTransformOneMinusT(float x, float y)
        {
            //Cubismから移植。
            LDVector2 v0 = new LDVector2(new LDPoint(x, y) - m_p2);
            LDVector2 v1 = new LDVector2(m_p1 - m_p2);
            LDVector2 v2 = new LDVector2(m_p0 - m_p2);
            double det = v1.x() * v2.y() - v1.y() * v2.x();

            double tx = (v2.y() * v0.x() - v2.x() * v0.y()) / det;
            double ty = (-v1.y() * v0.x() + v1.x() * v0.y()) / det;

            return new LDPoint(1 - (float)tx, 1 - (float)ty);
        }
示例#3
0
        public LDPoint inverseTransform(float x, float y)
        {
            //三角形の1点を基準点とする(この場合index0番)
            //基準点から2辺に向かうベクトルをV1,V2とし、(x,y)へ向かうベクトルをV0とする
            //V0 = s*V1 + t*V2
            //とするとき
            //(s,t) = ((V1*V2)の逆行列) * V0

            //Cubismから移植。
            LDVector2 v0 = new LDVector2(new LDPoint(x, y) - m_p0);
            LDVector2 v1 = new LDVector2(m_p1 - m_p0);
            LDVector2 v2 = new LDVector2(m_p2 - m_p0);

            double det = v1.x() * v2.y() - v1.y() * v2.x();

            double tx = (v2.y() * v0.x() - v2.x() * v0.y()) / det;
            double ty = (-v1.y() * v0.x() + v1.x() * v0.y()) / det;

            return(new LDPoint((float)tx, (float)ty));
        }
示例#4
0
        public LDPoint inverseTransform(float x, float y)
        {
            //三角形の1点を基準点とする(この場合index0番)
            //基準点から2辺に向かうベクトルをV1,V2とし、(x,y)へ向かうベクトルをV0とする
            //V0 = s*V1 + t*V2
            //とするとき
            //(s,t) = ((V1*V2)の逆行列) * V0

            //Cubismから移植。
            LDVector2 v0 = new LDVector2(new LDPoint(x, y) - m_p0);
            LDVector2 v1 = new LDVector2(m_p1 - m_p0);
            LDVector2 v2 = new LDVector2(m_p2 - m_p0);

            double det = v1.x() * v2.y() - v1.y() * v2.x();

            double tx = (v2.y() * v0.x() - v2.x() * v0.y()) / det;
            double ty = (-v1.y() * v0.x() + v1.x() * v0.y()) / det;

            return new LDPoint((float)tx, (float)ty);
        }
示例#5
0
        /**
         * v1からv2への反時計回りの角度 (0~2pi)
         */
        public static double getAngle(LDVector2 v1, LDVector2 v2)
        {
            double q1  = Math.Atan2(v1.y(), v1.x());
            double q2  = Math.Atan2(v2.y(), v2.x());
            double ret = q2 - q1;//v2の角度からv1 の角度を引く

            if (ret < 0)
            {
                ret += 2 * PI;         //0より小さければ、360度足す
            }
            return(ret);
        }