blob: 85c9479ed0f7590472ac5944b6ded4d52ce8e512 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
using System.Diagnostics;
namespace LibNoise.Operator
{
/// <summary>
/// Provides a noise module that scales the coordinates of the input value before
/// returning the output value from a source module. [OPERATOR]
/// </summary>
public class Scale : ModuleBase
{
#region Fields
private double _x = 1.0;
private double _y = 1.0;
private double _z = 1.0;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of Scale.
/// </summary>
public Scale()
: base(1)
{
}
/// <summary>
/// Initializes a new instance of Scale.
/// </summary>
/// <param name="input">The input module.</param>
public Scale(ModuleBase input)
: base(1)
{
Modules[0] = input;
}
/// <summary>
/// Initializes a new instance of Scale.
/// </summary>
/// <param name="x">The scaling on the x-axis.</param>
/// <param name="y">The scaling on the y-axis.</param>
/// <param name="z">The scaling on the z-axis.</param>
/// <param name="input">The input module.</param>
public Scale(double x, double y, double z, ModuleBase input)
: base(1)
{
Modules[0] = input;
X = x;
Y = y;
Z = z;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the scaling factor on the x-axis.
/// </summary>
public double X
{
get { return _x; }
set { _x = value; }
}
/// <summary>
/// Gets or sets the scaling factor on the y-axis.
/// </summary>
public double Y
{
get { return _y; }
set { _y = value; }
}
/// <summary>
/// Gets or sets the scaling factor on the z-axis.
/// </summary>
public double Z
{
get { return _z; }
set { _z = value; }
}
#endregion
#region ModuleBase Members
/// <summary>
/// Returns the output value for the given input coordinates.
/// </summary>
/// <param name="x">The input coordinate on the x-axis.</param>
/// <param name="y">The input coordinate on the y-axis.</param>
/// <param name="z">The input coordinate on the z-axis.</param>
/// <returns>The resulting output value.</returns>
public override double GetValue(double x, double y, double z)
{
Debug.Assert(Modules[0] != null);
return Modules[0].GetValue(x * _x, y * _y, z * _z);
}
#endregion
}
}
|