UnityEngine.UI.Extensions.CUIGraphic.solveDoubleEquationWithVector(float, float, float, float, UnityEngine.Vector3, UnityEngine.Vector3, out UnityEngine.Vector3, out UnityEngine.Vector3)

Here are the examples of the csharp api UnityEngine.UI.Extensions.CUIGraphic.solveDoubleEquationWithVector(float, float, float, float, UnityEngine.Vector3, UnityEngine.Vector3, out UnityEngine.Vector3, out UnityEngine.Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : CUIGraphic.cs
License : MIT License
Project Creator : cmaher

public void ReferenceCUIForBCurves()
        {
            // compute the position ratio of this rect transform in perspective of reference rect transform

            Vector3 posDeltaBetweenBottomLeftCorner = rectTrans.localPosition;// Difference between pivot

            posDeltaBetweenBottomLeftCorner.x += -rectTrans.rect.width * rectTrans.pivot.x + (refCUIGraphic.rectTrans.rect.width * refCUIGraphic.rectTrans.pivot.x);
            posDeltaBetweenBottomLeftCorner.y += -rectTrans.rect.height * rectTrans.pivot.y + (refCUIGraphic.rectTrans.rect.height * refCUIGraphic.rectTrans.pivot.y);
            //posDeltaBetweenBottomLeftCorner.z = rectTrans.localPosition.z;

            Vector3 bottomLeftPosRatio = new Vector3(posDeltaBetweenBottomLeftCorner.x / refCUIGraphic.RectTrans.rect.width, posDeltaBetweenBottomLeftCorner.y / refCUIGraphic.RectTrans.rect.height, posDeltaBetweenBottomLeftCorner.z);
            Vector3 topRightPosRatio = new Vector3((posDeltaBetweenBottomLeftCorner.x + rectTrans.rect.width) / refCUIGraphic.RectTrans.rect.width, (posDeltaBetweenBottomLeftCorner.y + rectTrans.rect.height) / refCUIGraphic.RectTrans.rect.height, posDeltaBetweenBottomLeftCorner.z);

            refCurves[0].ControlPoints[0] = refCUIGraphic.GetBCurveSandwichSpacePoint(bottomLeftPosRatio.x, bottomLeftPosRatio.y) - rectTrans.localPosition;
            refCurves[0].ControlPoints[3] = refCUIGraphic.GetBCurveSandwichSpacePoint(topRightPosRatio.x, bottomLeftPosRatio.y) - rectTrans.localPosition;

            refCurves[1].ControlPoints[0] = refCUIGraphic.GetBCurveSandwichSpacePoint(bottomLeftPosRatio.x, topRightPosRatio.y) - rectTrans.localPosition;
            refCurves[1].ControlPoints[3] = refCUIGraphic.GetBCurveSandwichSpacePoint(topRightPosRatio.x, topRightPosRatio.y) - rectTrans.localPosition;

            // use two sample points from the reference curves to find the second and third controls points for this curves
            for (int c = 0; c < refCurves.Length; c++)
            {
                CUIBezierCurve curve = refCurves[c];

                float yTime = c == 0 ? bottomLeftPosRatio.y : topRightPosRatio.y;

                Vector3 leftPoint = refCUIGraphic.GetBCurveSandwichSpacePoint(bottomLeftPosRatio.x, yTime);
                Vector3 rightPoint = refCUIGraphic.GetBCurveSandwichSpacePoint(topRightPosRatio.x, yTime);

                float quarter = 0.25f,
                threeQuarter = 0.75f;

                Vector3 quarterPoint = refCUIGraphic.GetBCurveSandwichSpacePoint((bottomLeftPosRatio.x * 0.75f + topRightPosRatio.x * 0.25f) / 1.0f, yTime);
                Vector3 threeQuaterPoint = refCUIGraphic.GetBCurveSandwichSpacePoint((bottomLeftPosRatio.x * 0.25f + topRightPosRatio.x * 0.75f) / 1.0f, yTime);

                float x_1 = 3 * threeQuarter * threeQuarter * quarter, // (1 - t)(1 - t)t
                    y_1 = 3 * threeQuarter * quarter * quarter,
                  x_2 = 3 * quarter * quarter * threeQuarter,
                  y_2 = 3 * quarter * threeQuarter * threeQuarter;

                Vector3 contant_1 = quarterPoint - Mathf.Pow(threeQuarter, 3) * leftPoint - Mathf.Pow(quarter, 3) * rightPoint,
                contant_2 = threeQuaterPoint - Mathf.Pow(quarter, 3) * leftPoint - Mathf.Pow(threeQuarter, 3) * rightPoint,
                p1,
                p2;

                solveDoubleEquationWithVector(x_1, y_1, x_2, y_2, contant_1, contant_2, out p1, out p2);

                curve.ControlPoints[1] = p1 - rectTrans.localPosition;
                curve.ControlPoints[2] = p2 - rectTrans.localPosition;

            }
            // use tangent and start and end time to derive control point 2 and 3
        }