diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs index d7e0dcd..10eaf71 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | ||
32 | 31 | ||
33 | namespace libTerrain | 32 | namespace libTerrain |
34 | { | 33 | { |
@@ -36,10 +35,10 @@ namespace libTerrain | |||
36 | { | 35 | { |
37 | private double[] CoordinatesToPolar(int x, int y) | 36 | private double[] CoordinatesToPolar(int x, int y) |
38 | { | 37 | { |
39 | double theta = Math.Atan2(x - (w / 2), y - (h / 2)); | 38 | double theta = Math.Atan2(x - (w/2), y - (h/2)); |
40 | double rx = (double)x - ((double)w / 2); | 39 | double rx = (double) x - ((double) w/2); |
41 | double ry = (double)y - ((double)h / 2); | 40 | double ry = (double) y - ((double) h/2); |
42 | double r = Math.Sqrt((rx * rx) + (ry * ry)); | 41 | double r = Math.Sqrt((rx*rx) + (ry*ry)); |
43 | 42 | ||
44 | double[] coords = new double[2]; | 43 | double[] coords = new double[2]; |
45 | coords[0] = r; | 44 | coords[0] = r; |
@@ -47,15 +46,16 @@ namespace libTerrain | |||
47 | return coords; | 46 | return coords; |
48 | } | 47 | } |
49 | 48 | ||
50 | public int[] PolarToCoordinates(double r, double theta) { | 49 | public int[] PolarToCoordinates(double r, double theta) |
50 | { | ||
51 | double nx; | 51 | double nx; |
52 | double ny; | 52 | double ny; |
53 | 53 | ||
54 | nx = (double)r * Math.Cos(theta); | 54 | nx = (double) r*Math.Cos(theta); |
55 | ny = (double)r * Math.Sin(theta); | 55 | ny = (double) r*Math.Sin(theta); |
56 | 56 | ||
57 | nx += w / 2; | 57 | nx += w/2; |
58 | ny += h / 2; | 58 | ny += h/2; |
59 | 59 | ||
60 | if (nx >= w) | 60 | if (nx >= w) |
61 | nx = w - 1; | 61 | nx = w - 1; |
@@ -70,8 +70,8 @@ namespace libTerrain | |||
70 | ny = 0; | 70 | ny = 0; |
71 | 71 | ||
72 | int[] coords = new int[2]; | 72 | int[] coords = new int[2]; |
73 | coords[0] = (int)nx; | 73 | coords[0] = (int) nx; |
74 | coords[1] = (int)ny; | 74 | coords[1] = (int) ny; |
75 | return coords; | 75 | return coords; |
76 | } | 76 | } |
77 | 77 | ||
@@ -79,19 +79,19 @@ namespace libTerrain | |||
79 | { | 79 | { |
80 | SetDiff(); | 80 | SetDiff(); |
81 | 81 | ||
82 | Channel n = this.Copy(); | 82 | Channel n = Copy(); |
83 | 83 | ||
84 | int x, y; | 84 | int x, y; |
85 | for (x = 0; x < w; x++) | 85 | for (x = 0; x < w; x++) |
86 | { | 86 | { |
87 | for (y = 0; y < h; y++) | 87 | for (y = 0; y < h; y++) |
88 | { | 88 | { |
89 | double[] coords = CoordinatesToPolar(x,y); | 89 | double[] coords = CoordinatesToPolar(x, y); |
90 | 90 | ||
91 | coords[0] += w / 2.0; | 91 | coords[0] += w/2.0; |
92 | coords[1] += h / 2.0; | 92 | coords[1] += h/2.0; |
93 | 93 | ||
94 | map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h]; | 94 | map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h]; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | } | 97 | } |
@@ -108,12 +108,13 @@ namespace libTerrain | |||
108 | r += incRadius; | 108 | r += incRadius; |
109 | theta += incAngle; | 109 | theta += incAngle; |
110 | 110 | ||
111 | int[] coords = PolarToCoordinates(r,theta); | 111 | int[] coords = PolarToCoordinates(r, theta); |
112 | Raise(coords[0], coords[1], 20, 1); | 112 | Raise(coords[0], coords[1], 20, 1); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c) | 116 | public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, |
117 | double[] c) | ||
117 | { | 118 | { |
118 | SetDiff(); | 119 | SetDiff(); |
119 | 120 | ||
@@ -128,7 +129,7 @@ namespace libTerrain | |||
128 | theta += incAngle; | 129 | theta += incAngle; |
129 | 130 | ||
130 | int[] coords = PolarToCoordinates(r, theta); | 131 | int[] coords = PolarToCoordinates(r, theta); |
131 | points.Add(new Point2D(coords[0],coords[1])); | 132 | points.Add(new Point2D(coords[0], coords[1])); |
132 | } | 133 | } |
133 | 134 | ||
134 | VoronoiDiagram(points, c); | 135 | VoronoiDiagram(points, c); |
@@ -145,9 +146,9 @@ namespace libTerrain | |||
145 | for (y = 0; y < h; y++) | 146 | for (y = 0; y < h; y++) |
146 | { | 147 | { |
147 | z++; | 148 | z++; |
148 | double dx = Math.Abs((w / 2) - x); | 149 | double dx = Math.Abs((w/2) - x); |
149 | double dy = Math.Abs((h / 2) - y); | 150 | double dy = Math.Abs((h/2) - y); |
150 | map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig); | 151 | map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig); |
151 | } | 152 | } |
152 | } | 153 | } |
153 | Normalise(); | 154 | Normalise(); |