本文整理汇总了C#中Surface.MergeX方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.MergeX方法的具体用法?C# Surface.MergeX怎么用?C# Surface.MergeX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.MergeX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSurfaceForParameters
/// <summary>
/// Provides the surface of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <param name="xParameter">The parameter used for the X axis</param>
/// <param name="yParameter">The parameter used for the Y axis</param>
/// <param name="explain"></param>
/// <returns></returns>
public virtual Surface CreateSurfaceForParameters(InterpretationContext context, Parameter xParameter,
Parameter yParameter, ExplanationPart explain)
{
Surface retVal = Surface;
if (retVal == null)
{
if (xParameter != null)
{
if (yParameter != null)
{
if (Cases.Count > 0)
{
retVal = new Surface(xParameter, yParameter);
foreach (Case cas in Cases)
{
if (PreconditionSatisfied(context, cas, xParameter, yParameter, explain))
{
Surface surface = cas.Expression.CreateSurface(context, xParameter, yParameter,
explain);
if (surface != null)
{
Parameter parameter = null;
surface = ReduceSurface(context, cas, surface, out parameter, explain);
if (parameter == null || parameter == surface.XParameter)
{
retVal.MergeX(surface);
}
else
{
retVal = Surface.MergeY(retVal, surface);
}
}
else
{
AddError("Cannot create surface for expression " + cas.ExpressionText);
retVal = null;
break;
}
}
}
}
else if (Graph != null)
{
// The function is defined by a graph
// Extend it to a surface
// TODO: Check the right parameter
retVal = Graph.ToSurfaceX();
retVal.XParameter = xParameter;
retVal.YParameter = yParameter;
}
else
{
AddError("cannot create surface for function " + Name + " with given parameters");
}
}
else
{
// Function with 1 parameter that ranges over the Xaxis
retVal = new Surface(xParameter, yParameter);
Graph graph = CreateGraphForParameter(context, xParameter, explain);
foreach (Graph.Segment segment in graph.Segments)
{
Graph newGraph = Graph.createGraph(segment.Expression.V0);
Surface.Segment newSegment = new Surface.Segment(segment.Start, segment.End, newGraph);
retVal.AddSegment(newSegment);
}
}
}
else if (yParameter != null)
{
// Function with 1 parameter that ranges over the Yaxis
retVal = new Surface(xParameter, yParameter);
Graph graph = CreateGraphForParameter(context, yParameter, explain);
Surface.Segment segment = new Surface.Segment(0, double.MaxValue, graph);
retVal.AddSegment(segment);
}
else
{
AddError("Invalid parameters for surface creation");
}
}
if (retVal != null)
{
retVal.XParameter = xParameter;
retVal.YParameter = yParameter;
}
return retVal;
//.........这里部分代码省略.........
示例2: createSurfaceForParameters
/// <summary>
/// Provides the surface of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <param name="Xparameter">The parameter used for the X axis</param>
/// <param name="Yparameter">The parameter used for the Y axis</param>
/// <returns></returns>
public virtual Surface createSurfaceForParameters(Interpreter.InterpretationContext context, Parameter Xparameter, Parameter Yparameter)
{
Surface retVal = Surface;
if (retVal == null)
{
if (Xparameter != null)
{
if (Yparameter != null)
{
if (Cases.Count > 0)
{
retVal = new Surface(Xparameter, Yparameter);
foreach (Case cas in Cases)
{
if (PreconditionSatisfied(context, cas, Xparameter, Yparameter))
{
Surface surface = cas.Expression.createSurface(context, Xparameter, Yparameter);
if (surface != null)
{
Parameter parameter = null;
surface = ReduceSurface(context, cas, surface, out parameter);
if (parameter == null || parameter == surface.XParameter)
{
retVal.MergeX(surface);
}
else
{
retVal = Surface.MergeY(retVal, surface);
}
}
else
{
AddError("Cannot create surface for expression " + cas.ExpressionText);
retVal = null;
break;
}
}
}
}
else if (Graph != null)
{
// The function is defined by a graph
// Extend it to a surface
// TODO: Check the right parameter
retVal = Graph.ToSurfaceX();
retVal.XParameter = Xparameter;
retVal.YParameter = Yparameter;
}
else
{
AddError("cannot create surface for function " + Name + " with given parameters");
}
}
else
{
// Function with 1 parameter that ranges over the Xaxis
retVal = new Surface(Xparameter, Yparameter);
Functions.Graph graph = createGraphForParameter(context, Xparameter);
foreach (Graph.Segment segment in graph.Segments)
{
Graph newGraph = Graph.createGraph(segment.Expression.v0);
Surface.Segment newSegment = new Surface.Segment(segment.Start, segment.End, newGraph);
retVal.AddSegment(newSegment);
}
}
}
else if (Yparameter != null)
{
// TODO : Remove check code
if ((Yparameter.Enclosing != this))
{
System.Diagnostics.Debugger.Break();
}
// Function with 1 parameter that ranges over the Yaxis
retVal = new Surface(Xparameter, Yparameter);
Graph graph = createGraphForParameter(context, Yparameter);
Surface.Segment segment = new Functions.Surface.Segment(0, double.MaxValue, graph);
retVal.AddSegment(segment);
}
else
{
AddError("Invalid parameters for surface creation");
}
}
retVal.XParameter = Xparameter;
retVal.YParameter = Yparameter;
return retVal;
//.........这里部分代码省略.........