public static IFunction Normalize(this FunctionTerm functionTerm, int depth) { if (functionTerm == null) { throw new ArgumentNullException("functionTerm"); } if (depth < 0) { throw new ArgumentOutOfRangeException("depth"); } functionTerm = CompleteNormalization.Rewrite(functionTerm); //Console.WriteLine(new string(' ', (2 - depth) * 4) + functionTerm); Console.Write("."); if (depth == 0) { return(functionTerm); } return(new ExplicitFunction ( functionTerm.DomainDimension, functionTerm.CodomainDimension, functionTerm.Evaluate, ( from derivative in functionTerm.GetDerivatives() select derivative.Normalize(depth - 1) ) .ToArray() )); }
public FunctionTermCurve(FunctionTerm function) { if (function == null) { throw new ArgumentNullException("function"); } if (function.DomainDimension != 1) { throw new ArgumentException("parameter 'function' has wrong domain dimension."); } if (function.CodomainDimension != 2) { throw new ArgumentException("parameter 'function' has wrong codomain dimension."); } this.point = function; this.velocity = point.GetDerivatives().Single(); this.acceleration = velocity.GetDerivatives().Single(); this.jerk = acceleration.GetDerivatives().Single(); ValueTerm position = Terms.Variable("t"); ValueTerm speedValue = Terms.Norm(velocity.Apply(position)); this.speed = speedValue.Abstract(position); ValueTerm directionValue = Terms.Angle(velocity.Apply(position)); this.direction = directionValue.Abstract(position); ValueTerm curvatureValue = Terms.Quotient(direction.GetDerivatives().Single().Apply(position), speedValue); this.curvature = curvatureValue.Abstract(position); }