Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SuperShapeVariation.cs
1using System;
4
6{
11 {
12 private readonly double m;
13 private readonly double n1;
14 private readonly double n2;
15 private readonly double n3;
16 private readonly double holes;
17 private readonly double rnd;
18
24 : base(new ScriptNode[] { m, n1, n2, n3, holes, rnd },
25 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
26 ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar },
28 {
29 this.m = 0;
30 this.n1 = 0;
31 this.n2 = 0;
32 this.n3 = 0;
33 this.holes = 0;
34 this.rnd = 0;
35 }
36
40 public SuperShapeVariation(double M, double N1, double N2, double N3,
41 double Holes, double Rnd, ScriptNode m, ScriptNode n1, ScriptNode n2, ScriptNode n3,
43 : base(new ScriptNode[] { m, n1, n2, n3, holes, rnd },
44 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
45 ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar },
47 {
48 this.m = M;
49 this.n1 = N1;
50 this.n2 = N2;
51 this.n3 = N3;
52 this.holes = Holes;
53 this.rnd = Rnd;
54 }
55
60 {
67
68 return new SuperShapeVariation(M, N1, N2, N3, Holes, Rnd, this.Arguments[0],
69 this.Arguments[1], this.Arguments[2], this.Arguments[3], this.Arguments[4],
70 this.Arguments[5], this.Start, this.Length, this.Expression);
71 }
72
76 public override string[] DefaultArgumentNames
77 {
78 get
79 {
80 return new string[] { "m", "n1", "n2", "n3", "holes", "rnd" };
81 }
82 }
83
87 public override void Operate(ref double x, ref double y)
88 {
89 double r1;
90
91 lock (this.gen)
92 {
93 r1 = this.gen.NextDouble();
94 }
95
96 double pneg1_n1 = -1.0 / this.n1;
97 double theta = (this.m * Math.Atan2(y, x) + Math.PI) / 4.0;
98 double t1 = Math.Pow(Math.Abs(Math.Sin(theta)), this.n2);
99 double t2 = Math.Pow(Math.Abs(Math.Cos(theta)), this.n3);
100 double r = Math.Sqrt(x * x + y * y) + 1e-6;
101 r = ((this.rnd * r1 + (1.0 - this.rnd) * r - this.holes) * Math.Pow(t1 + t2, pneg1_n1)) / r;
102 x *= r;
103 y *= r;
104 }
105
106 private readonly Random gen = new Random();
107
111 public override string FunctionName => nameof(SuperShapeVariation);
112 }
113}
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
SuperShapeVariation(double M, double N1, double N2, double N3, double Holes, double Rnd, ScriptNode m, ScriptNode n1, ScriptNode n2, ScriptNode n3, ScriptNode holes, ScriptNode rnd, int Start, int Length, Expression Expression)
TODO
SuperShapeVariation(ScriptNode m, ScriptNode n1, ScriptNode n2, ScriptNode n3, ScriptNode holes, ScriptNode rnd, int Start, int Length, Expression Expression)
TODO
override void Operate(ref double x, ref double y)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
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