Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Plot2DCurve.cs
1using System;
2using SkiaSharp;
7
9{
19 {
20 private static readonly ArgumentType[] argumentTypes4Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar, ArgumentType.Scalar };
21 private static readonly ArgumentType[] argumentTypes3Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar };
22 private static readonly ArgumentType[] argumentTypes2Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector };
23
33 : base(new ScriptNode[] { X, Y }, argumentTypes2Parameters, Start, Length, Expression)
34 {
35 }
36
47 : base(new ScriptNode[] { X, Y, Color }, argumentTypes3Parameters, Start, Length, Expression)
48 {
49 }
50
62 : base(new ScriptNode[] { X, Y, Color, Size }, argumentTypes4Parameters, Start, Length, Expression)
63 {
64 }
65
69 public override string FunctionName => nameof(Plot2DCurve);
70
74 public override string[] Aliases
75 {
76 get
77 {
78 return new string[] { "plot2dspline" };
79 }
80 }
81
85 public override string[] DefaultArgumentNames
86 {
87 get { return new string[] { "x", "y", "color", "size" }; }
88 }
89
97 {
98 if (!(Arguments[0] is IVector X))
99 throw new ScriptRuntimeException("Expected vector for X argument.", this);
100
101 if (!(Arguments[1] is IVector Y))
102 throw new ScriptRuntimeException("Expected vector for Y argument.", this);
103
104 int Dimension = X.Dimension;
105 if (Y.Dimension != Dimension)
106 throw new VectorSizeMismatchScriptException(this);
107
108 IElement Color = Arguments.Length <= 2 ? null : Arguments[2];
109 IElement Size = Arguments.Length <= 3 ? null : Arguments[3];
110
111 return new Graph2D(Variables, X, Y, new Plot2DCurvePainter(), false, false, this,
112 Color?.AssociatedObjectValue ?? Graph.DefaultColor, Size?.AssociatedObjectValue ?? 2.0);
113 }
114
120 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
121 public static SKPath CreateSpline(params SKPoint[] Points)
122 {
123 return Plot2DCurvePainter.CreateSpline(Points);
124 }
125
132 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
133 public static SKPath CreateSpline(SKPath AppendTo, params SKPoint[] Points)
134 {
135 return Plot2DCurvePainter.CreateSpline(AppendTo, Points);
136 }
137
144 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
145 public static void GetCubicBezierCoefficients(double[] V, out double[] A, out double[] B)
146 {
148 }
149
150 }
151}
Class managing a script expression.
Definition: Expression.cs:41
static SKPath CreateSpline(params SKPoint[] Points)
Creates a Spline path through a given set of points.
Definition: Plot2DCurve.cs:121
Plot2DCurve(ScriptNode X, ScriptNode Y, ScriptNode Color, ScriptNode Size, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:61
Plot2DCurve(ScriptNode X, ScriptNode Y, ScriptNode Color, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:46
override string[] Aliases
Optional aliases. If there are no aliases for the function, null is returned.
Definition: Plot2DCurve.cs:75
override string FunctionName
Name of the function
Definition: Plot2DCurve.cs:69
override string[] DefaultArgumentNames
Default Argument names
Definition: Plot2DCurve.cs:86
static void GetCubicBezierCoefficients(double[] V, out double[] A, out double[] B)
Gets a set of coefficients for cubic Bezier curves, forming a spline, one coordinate at a time.
Definition: Plot2DCurve.cs:145
Plot2DCurve(ScriptNode X, ScriptNode Y, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:32
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: Plot2DCurve.cs:96
static SKPath CreateSpline(SKPath AppendTo, params SKPoint[] Points)
Creates a Spline path through a given set of points.
Definition: Plot2DCurve.cs:133
static SKPath CreateSpline(params SKPoint[] Points)
Creates a Spline path through a given set of points.
Handles two-dimensional graphs.
Definition: Graph2D.cs:27
Base class for graphs.
Definition: Graph.cs:88
static readonly SKColor DefaultColor
Default color: Red
Definition: Graph.cs:127
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:34
Basic interface for vectors.
Definition: IVector.cs:9
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9