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;
6
8{
18 {
19 private static readonly ArgumentType[] argumentTypes4Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar, ArgumentType.Scalar };
20 private static readonly ArgumentType[] argumentTypes3Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar };
21 private static readonly ArgumentType[] argumentTypes2Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector };
22
32 : base(new ScriptNode[] { X, Y }, argumentTypes2Parameters, Start, Length, Expression)
33 {
34 }
35
46 : base(new ScriptNode[] { X, Y, Color }, argumentTypes3Parameters, Start, Length, Expression)
47 {
48 }
49
61 : base(new ScriptNode[] { X, Y, Color, Size }, argumentTypes4Parameters, Start, Length, Expression)
62 {
63 }
64
68 public override string FunctionName => nameof(Plot2DCurve);
69
73 public override string[] Aliases
74 {
75 get
76 {
77 return new string[] { "plot2dspline" };
78 }
79 }
80
84 public override string[] DefaultArgumentNames
85 {
86 get { return new string[] { "x", "y", "color", "size" }; }
87 }
88
96 {
97 if (!(Arguments[0] is IVector X))
98 throw new ScriptRuntimeException("Expected vector for X argument.", this);
99
100 if (!(Arguments[1] is IVector Y))
101 throw new ScriptRuntimeException("Expected vector for Y argument.", this);
102
103 int Dimension = X.Dimension;
104 if (Y.Dimension != Dimension)
105 throw new ScriptRuntimeException("Vector size mismatch.", this);
106
107 IElement Color = Arguments.Length <= 2 ? null : Arguments[2];
108 IElement Size = Arguments.Length <= 3 ? null : Arguments[3];
109
110 return new Graph2D(Variables, X, Y, new Plot2DCurvePainter(), false, false, this,
111 Color?.AssociatedObjectValue ?? Graph.DefaultColor, Size?.AssociatedObjectValue ?? 2.0);
112 }
113
119 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
120 public static SKPath CreateSpline(params SKPoint[] Points)
121 {
122 return Plot2DCurvePainter.CreateSpline(Points);
123 }
124
131 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
132 public static SKPath CreateSpline(SKPath AppendTo, params SKPoint[] Points)
133 {
134 return Plot2DCurvePainter.CreateSpline(AppendTo, Points);
135 }
136
143 [Obsolete("Method moved to the Plot2DCurvePainter class.")]
144 public static void GetCubicBezierCoefficients(double[] V, out double[] A, out double[] B)
145 {
147 }
148
149 }
150}
Class managing a script expression.
Definition: Expression.cs:39
static SKPath CreateSpline(params SKPoint[] Points)
Creates a Spline path through a given set of points.
Definition: Plot2DCurve.cs:120
Plot2DCurve(ScriptNode X, ScriptNode Y, ScriptNode Color, ScriptNode Size, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:60
Plot2DCurve(ScriptNode X, ScriptNode Y, ScriptNode Color, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:45
override string[] Aliases
Optional aliases. If there are no aliases for the function, null is returned.
Definition: Plot2DCurve.cs:74
override string FunctionName
Name of the function
Definition: Plot2DCurve.cs:68
override string[] DefaultArgumentNames
Default Argument names
Definition: Plot2DCurve.cs:85
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:144
Plot2DCurve(ScriptNode X, ScriptNode Y, int Start, int Length, Expression Expression)
Plots a two-dimensional curve.
Definition: Plot2DCurve.cs:31
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: Plot2DCurve.cs:95
static SKPath CreateSpline(SKPath AppendTo, params SKPoint[] Points)
Creates a Spline path through a given set of points.
Definition: Plot2DCurve.cs:132
static SKPath CreateSpline(params SKPoint[] Points)
Creates a Spline path through a given set of points.
Handles two-dimensional graphs.
Definition: Graph2D.cs:26
Base class for graphs.
Definition: Graph.cs:79
static readonly SKColor DefaultColor
Default color: Red
Definition: Graph.cs:118
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:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
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