blob: 8da7799d9d76417f69dcd14075cfefa0963d2727 (
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
|
using System.Diagnostics;
namespace LibNoise.Operator
{
/// <summary>
/// Provides a noise module that applies a scaling factor and a bias to the output
/// value from a source module. [OPERATOR]
/// </summary>
public class ScaleBias : ModuleBase
{
#region Constructors
/// <summary>
/// Initializes a new instance of ScaleBias.
/// </summary>
public ScaleBias()
: base(1)
{
Scale = 1;
}
/// <summary>
/// Initializes a new instance of ScaleBias.
/// </summary>
/// <param name="input">The input module.</param>
public ScaleBias(ModuleBase input)
: base(1)
{
Modules[0] = input;
Scale = 1;
}
/// <summary>
/// Initializes a new instance of ScaleBias.
/// </summary>
/// <param name="scale">The scaling factor to apply to the output value from the source module.</param>
/// <param name="bias">The bias to apply to the scaled output value from the source module.</param>
/// <param name="input">The input module.</param>
public ScaleBias(double scale, double bias, ModuleBase input)
: base(1)
{
Modules[0] = input;
Bias = bias;
Scale = scale;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the bias to apply to the scaled output value from the source module.
/// </summary>
public double Bias { get; set; }
/// <summary>
/// Gets or sets the scaling factor to apply to the output value from the source module.
/// </summary>
public double Scale { get; set; }
#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, y, z) * Scale + Bias;
}
#endregion
}
}
|