Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Disc2Variation.cs
1using System;
4
6{
11 {
12 private readonly double rotation;
13 private readonly double twist;
14
19 : base(new ScriptNode[] { rotation, twist }, new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar },
21 {
22 this.rotation = 0;
23 this.twist = 0;
24 }
25
26 private Disc2Variation(double Rotation, double Twist, ScriptNode rotation, ScriptNode twist, int Start, int Length, Expression Expression)
27 : base(new ScriptNode[] { rotation, twist }, new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar },
29 {
30 this.rotation = Rotation;
31 this.twist = Twist;
32 }
33
37 public override string[] DefaultArgumentNames
38 {
39 get
40 {
41 return new string[] { "rotation", "twist" };
42 }
43 }
44
49 {
52
53 return new Disc2Variation(Rotation, Twist, this.Arguments[0], this.Arguments[1],
54 this.Start, this.Length, this.Expression);
55 }
56
60 public override void Operate(ref double x, ref double y)
61 {
62 double d2rtp = this.rotation * Math.PI;
63 double s0 = Math.Sin(this.twist);
64 double c0 = Math.Cos(this.twist);
65
66 if (this.twist > pi2)
67 {
68 double k = 1 + this.twist - pi2;
69 s0 *= k;
70 c0 *= k;
71 }
72
73 if (this.twist < -pi2)
74 {
75 double k = 1 + this.twist + pi2;
76 s0 *= k;
77 c0 *= k;
78
79 }
80
81 double t = d2rtp * (x + y);
82 double sinr = Math.Sin(t);
83 double cosr = Math.Cos(t);
84 double r = Math.Atan2(x, y) / Math.PI;
85 x = (sinr + c0) * r;
86 y = (cosr + s0) * r;
87 }
88
89 private const double pi2 = 2 * Math.PI;
90
94 public override string FunctionName => nameof(Disc2Variation);
95 }
96}
Class managing a script expression.
Definition: Expression.cs:39
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:4824
override void Operate(ref double x, ref double y)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
Disc2Variation(ScriptNode rotation, ScriptNode twist, int Start, int Length, Expression Expression)
TODO
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
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9