aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-21 22:25:42 +0000
committerAdam Frisby2007-07-21 22:25:42 +0000
commitf84937367f7180140bd17444d507977f9b7e3d2e (patch)
tree944f2824669e42b5df3b6655bd09999c89b50376 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
parent* Renamed terrain functions to match OpenSim naming styles. (diff)
downloadopensim-SC-f84937367f7180140bd17444d507977f9b7e3d2e.zip
opensim-SC-f84937367f7180140bd17444d507977f9b7e3d2e.tar.gz
opensim-SC-f84937367f7180140bd17444d507977f9b7e3d2e.tar.bz2
opensim-SC-f84937367f7180140bd17444d507977f9b7e3d2e.tar.xz
* Deleted libTerrain-BSD.dll
* Added libTerrain to BasicTerrain directly as a subfolder
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs221
1 files changed, 221 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
new file mode 100644
index 0000000..81db690
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
@@ -0,0 +1,221 @@
1/*
2Redistribution and use in source and binary forms, with or without
3modification, are permitted provided that the following conditions are
4met:
5
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following
11 disclaimer in the documentation and/or other materials provided
12 with the distribution.
13
14 * Neither the name of libTerrain nor the names of
15 its contributors may be used to endorse or promote products
16 derived from this software without specific prior written
17 permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*/
31
32using System;
33using System.Collections.Generic;
34using System.Text;
35
36namespace libTerrain
37{
38 partial class Channel
39 {
40 /* Operator combination of channel datatypes */
41
42 public static Channel operator +(Channel A, Channel B)
43 {
44 if (A.h != B.h)
45 throw new Exception("Cannot add heightmaps, of different height.");
46 if (A.w != B.w)
47 throw new Exception("Cannot add heightmaps, of different width.");
48
49 int x, y;
50
51 for (x = 0; x < A.w; x++)
52 {
53 for (y = 0; y < A.h; y++)
54 {
55 A.map[x, y] += B.map[x, y];
56 }
57 }
58
59 return A;
60 }
61
62 public static Channel operator *(Channel A, Channel B)
63 {
64 if (A.h != B.h)
65 throw new Exception("Cannot multiply heightmaps, of different height.");
66 if (A.w != B.w)
67 throw new Exception("Cannot multiply heightmaps, of different width.");
68
69 int x, y;
70
71 for (x = 0; x < A.w; x++)
72 {
73 for (y = 0; y < A.h; y++)
74 {
75 A.map[x, y] *= B.map[x, y];
76 }
77 }
78
79 return A;
80 }
81
82 public static Channel operator -(Channel A, Channel B)
83 {
84 if (A.h != B.h)
85 throw new Exception("Cannot subtract heightmaps, of different height.");
86 if (A.w != B.w)
87 throw new Exception("Cannot subtract heightmaps, of different width.");
88
89 int x, y;
90
91 for (x = 0; x < A.w; x++)
92 {
93 for (y = 0; y < A.h; y++)
94 {
95 A.map[x, y] -= B.map[x, y];
96 }
97 }
98
99 return A;
100 }
101
102 public static Channel operator /(Channel A, Channel B)
103 {
104 if (A.h != B.h)
105 throw new Exception("Cannot divide heightmaps, of different height.");
106 if (A.w != B.w)
107 throw new Exception("Cannot divide heightmaps, of different width.");
108
109 int x, y;
110
111 for (x = 0; x < A.w; x++)
112 {
113 for (y = 0; y < A.h; y++)
114 {
115 A.map[x, y] /= B.map[x, y];
116 }
117 }
118
119 return A;
120 }
121
122 public static Channel operator ^(Channel A, Channel B)
123 {
124 if (A.h != B.h)
125 throw new Exception("Cannot divide heightmaps, of different height.");
126 if (A.w != B.w)
127 throw new Exception("Cannot divide heightmaps, of different width.");
128
129 int x, y;
130
131 for (x = 0; x < A.w; x++)
132 {
133 for (y = 0; y < A.h; y++)
134 {
135 A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]);
136 }
137 }
138
139 return A;
140 }
141
142
143 /* Operator combination of channel and double datatypes */
144
145 public static Channel operator +(Channel A, double B)
146 {
147 int x, y;
148
149 for (x = 0; x < A.w; x++)
150 {
151 for (y = 0; y < A.h; y++)
152 {
153 A.map[x, y] += B;
154 }
155 }
156
157 return A;
158 }
159
160 public static Channel operator -(Channel A, double B)
161 {
162 int x, y;
163
164 for (x = 0; x < A.w; x++)
165 {
166 for (y = 0; y < A.h; y++)
167 {
168 A.map[x, y] -= B;
169 }
170 }
171
172 return A;
173 }
174
175 public static Channel operator *(Channel A, double B)
176 {
177 int x, y;
178
179 for (x = 0; x < A.w; x++)
180 {
181 for (y = 0; y < A.h; y++)
182 {
183 A.map[x, y] *= B;
184 }
185 }
186
187 return A;
188 }
189
190 public static Channel operator /(Channel A, double B)
191 {
192 int x, y;
193
194 for (x = 0; x < A.w; x++)
195 {
196 for (y = 0; y < A.h; y++)
197 {
198 A.map[x, y] /= B;
199 }
200 }
201
202 return A;
203 }
204
205 public static Channel operator ^(Channel A, double B)
206 {
207 int x, y;
208
209 for (x = 0; x < A.w; x++)
210 {
211 for (y = 0; y < A.h; y++)
212 {
213 A.map[x, y] = Math.Pow(A.map[x,y],B);
214 }
215 }
216
217 return A;
218 }
219
220 }
221}