示例#1
0
 public static FloatVariable operator *(double k, FloatVariable a)
 {
     return(a.CSP.Memoize(
                "*",
                () =>
     {
         var product = new FloatVariable("product", a.CSP, k * a.Value);
         // ReSharper disable ObjectCreationAsStatement
         new ProductConstantConstraint(product, a, k);
         // ReSharper restore ObjectCreationAsStatement
         return product;
     },
                k,
                a));
 }
示例#2
0
 public static FloatVariable operator /(FloatVariable a, FloatVariable b)
 {
     return(a.CSP.Memoize(
                "/",
                () =>
     {
         var quotient = new FloatVariable("quotient", a.CSP, a.Value / b.Value);
         // ReSharper disable ObjectCreationAsStatement
         new QuotientConstraint(quotient, a, b);
         // ReSharper restore ObjectCreationAsStatement
         return quotient;
     },
                a,
                b));
 }
示例#3
0
 public static FloatVariable operator -(FloatVariable a, FloatVariable b)
 {
     return(a.CSP.Memoize(
                "-",
                () =>
     {
         var difference = new FloatVariable("difference", a.CSP, a.Value - b.Value);
         // ReSharper disable ObjectCreationAsStatement
         new DifferenceConstraint(difference, a, b);
         // ReSharper restore ObjectCreationAsStatement
         return difference;
     },
                a,
                b));
 }
示例#4
0
 public static FloatVariable operator +(FloatVariable a, FloatVariable b)
 {
     return(a.CSP.Memoize(
                "+",
                () =>
     {
         var sum = new FloatVariable("sum", a.CSP, a.Value + b.Value);
         // ReSharper disable ObjectCreationAsStatement
         new SumConstraint(sum, a, b);
         // ReSharper restore ObjectCreationAsStatement
         return sum;
     },
                a,
                b));
 }
示例#5
0
 public static FloatVariable Dot(Vector3Variable a, Vector3Variable b)
 {
     return(a.X.CSP.Memoize(
                "dot",
                () =>
     {
         var product = new FloatVariable(
             string.Format("{0} dot {1}", a.Name, b.Name),
             a.X.CSP,
             a.X.Value * b.X.Value + a.Y.Value * b.Y.Value + a.Z.Value * b.Z.Value);
         // ReSharper disable ObjectCreationAsStatement
         new DotProductConstraint(product, a, b);
         // ReSharper restore ObjectCreationAsStatement
         return product;
     },
                a,
                b));
 }
示例#6
0
        public void MustBeParallel(Vector3Variable v)
        {
            var coefficient = new FloatVariable("parallelCoefficient", CSP, Interval.AllValues);

            this.MustEqual(coefficient * v);
        }
 public override void CanonicalizeVariables()
 {
     difference = RegisterCanonical <FloatVariable, Interval>(difference);
     a          = RegisterCanonical <FloatVariable, Interval>(a);
     b          = RegisterCanonical <FloatVariable, Interval>(b);
 }
 public override void CanonicalizeVariables()
 {
     sum = RegisterCanonical <FloatVariable, Interval>(sum);
     a   = RegisterCanonical <FloatVariable, Interval>(a);
     b   = RegisterCanonical <FloatVariable, Interval>(b);
 }
 public override void CanonicalizeVariables()
 {
     power = RegisterCanonical <FloatVariable, Interval>(power);
     a     = RegisterCanonical <FloatVariable, Interval>(a);
 }
 public override void CanonicalizeVariables()
 {
     quotient = RegisterCanonical <FloatVariable, Interval>(quotient);
     a        = RegisterCanonical <FloatVariable, Interval>(a);
     b        = RegisterCanonical <FloatVariable, Interval>(b);
 }
 public override void CanonicalizeVariables()
 {
     this.magnitude = RegisterCanonical <FloatVariable, Interval>(this.magnitude);
     this.vector.CanonicalizeAndRegisterConstraint(this);
 }
示例#12
0
 // This is needed to prevent the compiler from trying to do an implicit conversion
 // of v to a double and then taking the MustEqual(double) overload.
 public void MustEqual(FloatVariable v)
 {
     MustEqual((Variable <Interval>)v);
 }
 public override void CanonicalizeVariables()
 {
     product = RegisterCanonical <FloatVariable, Interval>(product);
     a.CanonicalizeAndRegisterConstraint(this);
     b.CanonicalizeAndRegisterConstraint(this);
 }
示例#14
0
 /// <summary>
 /// Update component variables to point at their canonical variables
 /// </summary>
 public void CanonicalizeAndRegisterConstraint(Constraint c)
 {
     X = c.RegisterCanonical <FloatVariable, Interval>(X);
     Y = c.RegisterCanonical <FloatVariable, Interval>(Y);
     Z = c.RegisterCanonical <FloatVariable, Interval>(Z);
 }
 public override void CanonicalizeVariables()
 {
     product = RegisterCanonical <FloatVariable, Interval>(product);
     a       = RegisterCanonical <FloatVariable, Interval>(a);
 }
示例#16
0
 public Vector3Variable(FloatVariable x, FloatVariable y, FloatVariable z)
 {
     X = x;
     Y = y;
     Z = z;
 }
 public MagnitudeConstraint(FloatVariable magnitude, Vector3Variable vector)
     : base(magnitude.CSP)
 {
     this.magnitude = magnitude;
     this.vector    = vector;
 }