Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NGonVariation.cs
1using System;
4
6{
11 {
12 private readonly double power;
13 private readonly double sides;
14 private readonly double corners;
15 private readonly double circle;
16
20 public NGonVariation(ScriptNode high, ScriptNode low, ScriptNode corners, ScriptNode circle,
22 : base(new ScriptNode[] { high, low, corners, circle },
23 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar },
25 {
26 this.power = 0;
27 this.sides = 0;
28 this.corners = 0;
29 this.circle = 0;
30 }
31
35 public NGonVariation(double High, double Low, double Corners, double Circle,
36 ScriptNode high, ScriptNode low, ScriptNode corners, ScriptNode circle,
38 : base(new ScriptNode[] { high, low, corners, circle },
39 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar },
41 {
42 this.power = High;
43 this.sides = Low;
44 this.corners = Corners;
45 this.circle = Circle;
46 }
47
51 public override string[] DefaultArgumentNames
52 {
53 get
54 {
55 return new string[] { "high", "low", "corners", "circle" };
56 }
57 }
58
63 {
68
69 return new NGonVariation(High, Low, Corners, Circle, this.Arguments[0],
70 this.Arguments[1], this.Arguments[2], this.Arguments[3], this.Start, this.Length,
71 this.Expression);
72 }
73
77 public override void Operate(ref double x, ref double y)
78 {
79 double p2 = Math.PI * 2 / this.sides;
80 double a = Math.Atan2(y, x);
81 double t3 = a - p2 * Math.Floor(a / p2);
82
83 if (t3 <= p2 * 0.5)
84 t3 -= p2;
85
86 double r = Math.Sqrt(x * x + y * y);
87 double k = (this.corners * (1 / (Math.Cos(t3) + 1e-6) - 1) + this.circle) / Math.Pow(r, this.power);
88 x *= k;
89 y *= k;
90 }
91
95 public override string FunctionName => nameof(NGonVariation);
96 }
97}
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
NGonVariation(double High, double Low, double Corners, double Circle, ScriptNode high, ScriptNode low, ScriptNode corners, ScriptNode circle, int Start, int Length, Expression Expression)
TODO
NGonVariation(ScriptNode high, ScriptNode low, ScriptNode corners, ScriptNode circle, 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