diff options
author | Adam Frisby | 2008-04-23 10:55:04 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-23 10:55:04 +0000 |
commit | 7c897043bab19bf748ac3078a05a74969c409fa7 (patch) | |
tree | f3f89972edbdebd9678025e754734f6aeb8b2952 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs | |
parent | * Get rid of missing texture notification drop messages for now - obscuring t... (diff) | |
download | opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.zip opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.gz opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.bz2 opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.xz |
* Removing old libTerrainBSD and associated Plugin & Project.
* Updated prebuild.xml accordingly.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs deleted file mode 100644 index a516d8d..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace libTerrain | ||
32 | { | ||
33 | partial class Channel | ||
34 | { | ||
35 | private double[] CoordinatesToPolar(int x, int y) | ||
36 | { | ||
37 | double theta = Math.Atan2(x - (w/2), y - (h/2)); | ||
38 | double rx = (double) x - ((double) w/2); | ||
39 | double ry = (double) y - ((double) h/2); | ||
40 | double r = Math.Sqrt((rx*rx) + (ry*ry)); | ||
41 | |||
42 | double[] coords = new double[2]; | ||
43 | coords[0] = r; | ||
44 | coords[1] = theta; | ||
45 | return coords; | ||
46 | } | ||
47 | |||
48 | public int[] PolarToCoordinates(double r, double theta) | ||
49 | { | ||
50 | double nx; | ||
51 | double ny; | ||
52 | |||
53 | nx = (double) r*Math.Cos(theta); | ||
54 | ny = (double) r*Math.Sin(theta); | ||
55 | |||
56 | nx += w/2; | ||
57 | ny += h/2; | ||
58 | |||
59 | if (nx >= w) | ||
60 | nx = w - 1; | ||
61 | |||
62 | if (ny >= h) | ||
63 | ny = h - 1; | ||
64 | |||
65 | if (nx < 0) | ||
66 | nx = 0; | ||
67 | |||
68 | if (ny < 0) | ||
69 | ny = 0; | ||
70 | |||
71 | int[] coords = new int[2]; | ||
72 | coords[0] = (int) nx; | ||
73 | coords[1] = (int) ny; | ||
74 | return coords; | ||
75 | } | ||
76 | |||
77 | public void Polar() | ||
78 | { | ||
79 | SetDiff(); | ||
80 | |||
81 | Channel n = Copy(); | ||
82 | |||
83 | int x, y; | ||
84 | for (x = 0; x < w; x++) | ||
85 | { | ||
86 | for (y = 0; y < h; y++) | ||
87 | { | ||
88 | double[] coords = CoordinatesToPolar(x, y); | ||
89 | |||
90 | coords[0] += w/2.0; | ||
91 | coords[1] += h/2.0; | ||
92 | |||
93 | map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h]; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle) | ||
99 | { | ||
100 | SetDiff(); | ||
101 | |||
102 | int i; | ||
103 | double r = offsetRadius; | ||
104 | double theta = offsetAngle; | ||
105 | for (i = 0; i < steps; i++) | ||
106 | { | ||
107 | r += incRadius; | ||
108 | theta += incAngle; | ||
109 | |||
110 | int[] coords = PolarToCoordinates(r, theta); | ||
111 | Raise(coords[0], coords[1], 20, 1); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, | ||
116 | double[] c) | ||
117 | { | ||
118 | SetDiff(); | ||
119 | |||
120 | List<Point2D> points = new List<Point2D>(); | ||
121 | |||
122 | int i; | ||
123 | double r = offsetRadius; | ||
124 | double theta = offsetAngle; | ||
125 | for (i = 0; i < steps; i++) | ||
126 | { | ||
127 | r += incRadius; | ||
128 | theta += incAngle; | ||
129 | |||
130 | int[] coords = PolarToCoordinates(r, theta); | ||
131 | points.Add(new Point2D(coords[0], coords[1])); | ||
132 | } | ||
133 | |||
134 | VoronoiDiagram(points, c); | ||
135 | } | ||
136 | |||
137 | public void Spiral(double wid, double hig, double offset) | ||
138 | { | ||
139 | SetDiff(); | ||
140 | |||
141 | int x, y, z; | ||
142 | z = 0; | ||
143 | for (x = 0; x < w; x++) | ||
144 | { | ||
145 | for (y = 0; y < h; y++) | ||
146 | { | ||
147 | z++; | ||
148 | double dx = Math.Abs((w/2) - x); | ||
149 | double dy = Math.Abs((h/2) - y); | ||
150 | map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig); | ||
151 | } | ||
152 | } | ||
153 | Normalise(); | ||
154 | } | ||
155 | } | ||
156 | } | ||