GetDirection(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3)

Here are the examples of the csharp api GetDirection(UnityEngine.Vector3, UnityEngine.Vector3, 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 : FillerStyle2D.cs
License : MIT License
Project Creator : MacSergey

private ITrajectory GetMiddleLine(FillerContour contour)
        {
            GetRails(contour, out ITrajectory left, out ITrajectory right);

            var leftLength = left.Length;
            var rightLength = right.Length;

            var leftRatio = leftLength / (leftLength + rightLength);
            var rightRatio = rightLength / (leftLength + rightLength);

            var straight = new StraightTrajectory((right.EndPosition + left.StartPosition) / 2, (right.StartPosition + left.EndPosition) / 2);
            var middle = new Bezier3()
            {
                a = (right.EndPosition + left.StartPosition) / 2,
                b = GetDirection(rightRatio * right.EndDirection, leftRatio * left.StartDirection, straight.StartDirection),
                c = GetDirection(rightRatio * right.StartDirection, leftRatio * left.EndDirection, straight.EndDirection),
                d = (right.StartPosition + left.EndPosition) / 2,
            };
            NetSegment.CalculateMiddlePoints(middle.a, middle.b, middle.d, middle.c, true, true, out middle.b, out middle.c);
            return new BezierTrajectory(middle);

            static Vector3 GetDirection(Vector3 left, Vector3 right, Vector3 straight)
            {
                var dir = (left + right).normalized;
                if (Vector2.Angle(XZ(left), XZ(right)) > 150f || Vector2.Angle(XZ(dir), XZ(straight)) > 90f)
                    dir = straight;

                return dir;
            }

        }