Example #1
0
        /// <summary>
        /// Multiply the x-component of a parametric equation by a function of input.
        /// </summary>
        /// <param name="f">Function of input</param>
        /// <param name="tp">Parametric equation</param>
        /// <returns></returns>
        public static ExTP MultiplyX(ExBPY f, ExTP tp)
        {
            var v  = TExV2.Variable();
            var by = ExUtils.VFloat();

            return(bpi => Ex.Block(
                       new[] { v, by },
                       Ex.Assign(v, tp(bpi)),
                       MulAssign(v.x, f(bpi)),
                       v
                       ));
        }
Example #2
0
        /// <summary>
        /// Add a function of input to the y-component of a parametric equation.
        /// </summary>
        /// <param name="f">Function of input</param>
        /// <param name="tp">Parametric equation</param>
        /// <returns></returns>
        public static ExTP AddY(ExBPY f, ExTP tp)
        {
            var v  = TExV2.Variable();
            var by = ExUtils.VFloat();

            return(bpi => Ex.Block(
                       new[] { v, by },
                       Ex.Assign(v, tp(bpi)),
                       ExUtils.AddAssign(v.y, f(bpi)),
                       v
                       ));
        }
Example #3
0
        /// <summary>
        /// Multiply a unit vector at a given angle from the target function by the magnitude,
        /// and add it to the target function.
        /// </summary>
        /// <param name="angle">Angle offset (degrees)</param>
        /// <param name="magnitude">Magnitude of offset vector</param>
        /// <param name="tp">Target function</param>
        /// <returns></returns>
        public static ExTP AddAtAngle(ExBPY angle, ExBPY magnitude, ExTP tp)
        {
            TExV2 v2     = TExV2.Variable();
            TExV2 v2norm = TExV2.Variable();
            var   mag    = ExUtils.VFloat();

            return(bpi => Ex.Block(new[] { v2, v2norm, mag },
                                   Ex.Assign(v2, tp(bpi)),
                                   Ex.Assign(v2norm, Rotate(angle(bpi), Norm(v2))),
                                   Ex.Assign(mag, magnitude(bpi)),
                                   Ex.Assign(v2norm.x, v2.x.Add(v2norm.x.Mul(mag))),
                                   Ex.Assign(v2norm.y, v2.y.Add(v2norm.y.Mul(mag))),
                                   v2norm
                                   ));
        }