Ejemplo n.º 1
0
        protected override sealed VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
        {
            var posX    = inputExpression[0].x - inputExpression[1].x;
            var posY    = inputExpression[0].y - inputExpression[1].y;
            var centerX = inputExpression[1].x;
            var centerY = inputExpression[1].y;

            var sinAngle = new VFXExpressionSin(inputExpression[2]);
            var cosAngle = new VFXExpressionCos(inputExpression[2]);

            var outPosX = centerX + ((posX * cosAngle) - (posY * sinAngle));
            var outPosY = centerY + ((posX * sinAngle) + (posY * cosAngle));

            return(new[] { new VFXExpressionCombine(outPosX, outPosY) });
        }
Ejemplo n.º 2
0
        public void ProcessExpressionTrig()
        {
            var a       = 1.5f;
            var b       = 2.1f;
            var resultA = Mathf.Cos(a);
            var resultB = Mathf.Sin(a);
            var resultC = Mathf.Tan(a);
            var resultD = Mathf.Acos(a);
            var resultE = Mathf.Asin(a);
            var resultF = Mathf.Atan(a);
            var resultG = Mathf.Atan2(a, b);

            var value_a = new VFXValue <float>(a);
            var value_b = new VFXValue <float>(b);

            var cosExpression   = new VFXExpressionCos(value_a);
            var sinExpression   = new VFXExpressionSin(value_a);
            var tanExpression   = new VFXExpressionTan(value_a);
            var acosExpression  = new VFXExpressionACos(value_a);
            var asinExpression  = new VFXExpressionASin(value_a);
            var atanExpression  = new VFXExpressionATan(value_a);
            var atan2Expression = new VFXExpressionATan2(value_a, value_b);

            var context     = new VFXExpression.Context(VFXExpressionContextOption.CPUEvaluation);
            var expressionA = context.Compile(cosExpression);
            var expressionB = context.Compile(sinExpression);
            var expressionC = context.Compile(tanExpression);
            var expressionD = context.Compile(acosExpression);
            var expressionE = context.Compile(asinExpression);
            var expressionF = context.Compile(atanExpression);
            var expressionG = context.Compile(atan2Expression);

            Assert.AreEqual(resultA, expressionA.Get <float>());
            Assert.AreEqual(resultB, expressionB.Get <float>());
            Assert.AreEqual(resultC, expressionC.Get <float>());
            Assert.AreEqual(resultD, expressionD.Get <float>());
            Assert.AreEqual(resultE, expressionE.Get <float>());
            Assert.AreEqual(resultF, expressionF.Get <float>());
            Assert.AreEqual(resultG, expressionG.Get <float>());
        }