Ejemplo n.º 1
0
        //s1,s2,s3で構成される三角形とt1,t2,t3が相似な三角形であるとき、、s1とs2の線とt1とt1を対応する線分である場合のt3の点を返す
        public static LDPoint getSimilarityTrianglePoint(LDPoint _s0, LDPoint _s1, LDPoint _s2, LDPoint _t0, LDPoint _t1)
        {
            LDVector2 s0 = new LDVector2(_s0);
            LDVector2 s1 = new LDVector2(_s1);
            LDVector2 s2 = new LDVector2(_s2);
            LDVector2 t0 = new LDVector2(_t0);
            LDVector2 t1 = new LDVector2(_t1);

            LDVector2 ss2   = s2 + t0 - s0;
            float     angle = (float)LDMathUtil.getAngle(s1 - s0, t1 - t0);
            LDPoint   sss2  = LDMathUtil.rotatePoint(_t0, ss2.toPoint(), -angle);
            LDVector2 v_s   = s1 - s0;
            LDVector2 v_t   = t1 - t0;
            float     scale = v_t.length() / v_s.length();
            LDPoint   t2    = LDMathUtil.scalePoint(_t0, sss2, scale);

            return(t2);
        }
Ejemplo n.º 2
0
        public static LDPolygon getHugeTriangle(LDRect rect)
        {
            Debug.Assert(rect.left() < rect.right());
            Debug.Assert(rect.top() < rect.bottom());

            // 1) 与えられた矩形を包含する円を求める
            //      円の中心 c = 矩形の中心
            //      円の半径 r = |p - c| + ρ
            //    ただし、pは与えられた矩形の任意の頂点
            //    ρは任意の正数
            LDVector2 center=new LDVector2(rect.center());
            LDVector2 topLeft=new LDVector2(rect.topLeft());
            float radius = center.distanceToPoint(topLeft);

            radius += 1.0f;//適当に大きくする

            // 2) その円に外接する正三角形を求める
            LDCircle circle=new LDCircle(center.toPoint(), radius);
            return circle.getCircumscribedTriangle();
        }
Ejemplo n.º 3
0
        public static LDPolygon getHugeTriangle(LDRect rect)
        {
            Debug.Assert(rect.left() < rect.right());
            Debug.Assert(rect.top() < rect.bottom());

            // 1) 与えられた矩形を包含する円を求める
            //      円の中心 c = 矩形の中心
            //      円の半径 r = |p - c| + ρ
            //    ただし、pは与えられた矩形の任意の頂点
            //    ρは任意の正数
            LDVector2 center  = new LDVector2(rect.center());
            LDVector2 topLeft = new LDVector2(rect.topLeft());
            float     radius  = center.distanceToPoint(topLeft);

            radius += 1.0f;//適当に大きくする

            // 2) その円に外接する正三角形を求める
            LDCircle circle = new LDCircle(center.toPoint(), radius);

            return(circle.getCircumscribedTriangle());
        }