Beispiel #1
0
    private void Update()
    {
        _positions[0] = new Vector3(A[0], A[1], 0);
        _positions[1] = new Vector3(B[0], B[1], 0);
        _positions[2] = new Vector3(C[0], C[1], 0);

        // (4) Meshに頂点情報を代入
        _mesh.vertices  = _positions;
        _mesh.triangles = _triangles;
        _mesh.normals   = _normals;

        _mesh.RecalculateBounds();

        // (5) 描画
        Graphics.DrawMesh(_mesh, Vector3.zero, Quaternion.identity, _material, 0);
        distanceAB = Math_and_PhysicsLib.distance2D(A, B);
        distanceBC = Math_and_PhysicsLib.distance2D(B, C);
        distanceCA = Math_and_PhysicsLib.distance2D(C, A);

        A2B2 = distanceAB * distanceAB + distanceBC * distanceBC;
        C2   = distanceCA * distanceCA;

        if (A2B2 == C2)
        {
            Debug.Log("直角三角形です");
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        float m;

        m = Math_and_PhysicsLib.slopeBetweenPoints(P1, P2);
        Debug.LogFormat("float:  " + m);
    }
 // Start is called before the first frame update
 void Start()
 {
     comp.x = x;
     comp.y = y;
     Math_and_PhysicsLib.CompToPolarConversion(comp, ref vec);
     mag = vec.mag;
     dir = vec.dir;
 }
 // Start is called before the first frame update
 void Start()
 {
     vec.mag = mag;
     vec.dir = dir;
     Math_and_PhysicsLib.PolarToCompConversion(vec, ref comp);
     x = comp.x;
     y = comp.y;
 }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        bool isVertical;

        isVertical = Math_and_PhysicsLib.arePerp(slope1, slope2);
        string verticalResult = isVertical ? "垂直です": "垂直じゃないです";

        Debug.LogFormat(verticalResult);
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        P1[0] = P1_transform.position.x;
        P1[1] = P1_transform.position.y;
        P2[0] = P2_transform.position.x;
        P2[1] = P2_transform.position.y;
        m     = Math_and_PhysicsLib.slopeBetweenPoints(P1, P2);
        lineRenderer.SetPosition(0, P1_transform.position);
        lineRenderer.SetPosition(1, P2_transform.position);

        // Debug.LogFormat("float:  "+ m);
    }
    // Update is called once per frame
    void Update()
    {
        sphere1.center[0] = target1.transform.position.x;
        sphere1.center[1] = target1.transform.position.y;
        sphere1.center[2] = target1.transform.position.z;

        sphere2.center[0]   = target2.transform.position.x;
        sphere2.center[1]   = target2.transform.position.y;
        sphere2.center[2]   = target2.transform.position.z;
        isColBetweenSpheres = Math_and_PhysicsLib.ColBetweenSpheres(ref sphere1, ref sphere2);

        if (isColBetweenSpheres)
        {
            Debug.Log("衝突した");
        }
    }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        P1[0]    = P1_transform.position.x;
        P1[1]    = P1_transform.position.y;
        P2[0]    = P2_transform.position.x;
        P2[1]    = P2_transform.position.y;
        m        = Math_and_PhysicsLib.slopeBetweenPoints(P1, P2);
        distance = Math_and_PhysicsLib.distance2D(P1, P2);
        IntPtr mid = Math_and_PhysicsLib.find2DMidPoint(P1, P2);

        Marshal.Copy(mid, midPoint, 0, 2);
        lineRenderer.SetPosition(0, P1_transform.position);
        lineRenderer.SetPosition(1, P2_transform.position);

        // Debug.LogFormat("float:  "+ m);
    }
Beispiel #9
0
    // Update is called once per frame
    void Update()
    {
        if (isGenarete)
        {
            if (straightLine == null)
            {
                straightLine = GameObject.CreatePrimitive(PrimitiveType.Cube);
            }
            // すべての子オブジェクトを取得して削除
            foreach (Transform childTransform in straightLine.transform)
            {
                GameObject.Destroy(childTransform.gameObject);
                childrenPosition.Clear();
            }

            for (int i = 0; i < 50; i++)
            {
                float      x    = i;
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

                float y = (a * x) + b;
                if (IsVerticalStraightLine)
                {
                    float m = Math_and_PhysicsLib.perpSlope(a);
                    y = m * (x - x1) + y1;
                }
                cube.transform.position = new Vector3(x, y, 0);
                cube.transform.parent   = straightLine.transform;
                childrenPosition.Add(cube.transform.position);

                //今の自分の地点まで直線を生成したら終わり
                if (x1 == x && y1 == y)
                {
                    //配列をリバースして移動しやすいようにする
                    if (IsVerticalStraightLine)
                    {
                        childrenPosition.Reverse();
                    }
                    isGenarete = false;
                    return;
                }
                Debug.Log(y);
            }
            isGenarete = false;
        }
    }
Beispiel #10
0
    // Start is called before the first frame update
    void Start()
    {
        //float[] m;
        IntPtr m;

        m = Math_and_PhysicsLib.lineIntersect(L1point, L1slope, L2point, L2slope);
        float[] arrayFloat = new float[2];
        Marshal.Copy(m, arrayFloat, 0, 2);

        Debug.Log("pointX:  " + arrayFloat[0]);
        Debug.Log("pointY:  " + arrayFloat[1]);
        //  Debug.LogFormat("float:  {0},{1}", m[0], m[1]);
        //  Debug.Log("pointX:  "+ m[0]);
        //  Debug.Log("pointY:  "+ m[1]);

        GenerateLine("straight1List", L1slope, L1point);
        GenerateLine("straight2List", L2slope, L2point);
    }
    // Start is called before the first frame update
    void Start()
    {
        P1[0] = player.position.x;
        P1[1] = player.position.y;
        P2[0] = target.position.x;
        P2[1] = target.position.y;
        atan  = Math_and_PhysicsLib.calcAngle2D(P1, P2);

        atan2 = (float)Mathf.Atan((P2[1] - P1[1]) / (P2[0] - P1[0])) * 57.29577951f;
        if (P2[1] < P1[1] && P2[0] > P1[0])
        {
        }
        else if ((P2[1] < P1[1] && P2[0] < P2[0]) || (P2[1] > P1[1] && P2[0] < P1[0]))
        {
            atan2 = atan2 + 180;
        }
        else
        {
            //    atan2 = atan2 + 360;
        }
    }
 public float VerticalStraightLine(float slope)
 {
     m = Math_and_PhysicsLib.perpSlope(slope);
     return(m);
 }
Beispiel #13
0
 // Start is called before the first frame update
 void Start()
 {
     m = Math_and_PhysicsLib.perpSlope(slope);
     Debug.LogFormat("与えられ直線に垂直な直線の傾き:  " + m);
 }