Revision 4b860361
Added by Leszek Koltunski 1 day ago
| src/main/java/org/distorted/library/type/Dynamic.kt | ||
|---|---|---|
| 22 | 22 |
|
| 23 | 23 |
import org.distorted.library.main.DistortedLibrary |
| 24 | 24 |
import kotlin.random.Random |
| 25 |
import java.util.Vector |
|
| 26 | 25 |
import kotlin.math.sqrt |
| 27 | 26 |
|
| 28 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 172 | 171 |
} |
| 173 | 172 |
} |
| 174 | 173 |
|
| 175 |
protected var vn: Vector<VectorNoise>? = null
|
|
| 174 |
protected var vn: MutableList<VectorNoise>? = null
|
|
| 176 | 175 |
protected lateinit var mFactor: FloatArray |
| 177 | 176 |
protected lateinit var mNoise: FloatArray |
| 178 | 177 |
protected lateinit var baseV: Array<FloatArray> |
| ... | ... | |
| 194 | 193 |
var path_ratio: FloatArray = FloatArray(NUM_RATIO) |
| 195 | 194 |
} |
| 196 | 195 |
|
| 197 |
protected var vc: Vector<VectorCache>? = null
|
|
| 196 |
protected var vc: MutableList<VectorCache>? = null
|
|
| 198 | 197 |
protected var mConvexity: Float = 0f |
| 199 | 198 |
|
| 200 | 199 |
private lateinit var buf: FloatArray |
| ... | ... | |
| 209 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 210 | 209 |
protected constructor(duration: Int, count: Float, dimension: Int) |
| 211 | 210 |
{
|
| 212 |
vc = Vector()
|
|
| 211 |
vc = mutableListOf()
|
|
| 213 | 212 |
vn = null |
| 214 | 213 |
numPoints = 0 |
| 215 | 214 |
cacheDirty = false |
| ... | ... | |
| 713 | 712 |
* @param mode [Dynamic.SPEED_MODE_SMOOTH] or [Dynamic.SPEED_MODE_SEGMENT_CONSTANT] or |
| 714 | 713 |
* [Dynamic.SPEED_MODE_GLOBALLY_CONSTANT] |
| 715 | 714 |
*/ |
| 715 |
@Synchronized |
|
| 716 | 716 |
fun setSpeedMode(mode: Int) |
| 717 | 717 |
{
|
| 718 | 718 |
if (mSpeedMode!=mode) |
| src/main/java/org/distorted/library/type/Dynamic1D.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sqrt |
| 25 | 24 |
|
| 26 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 29 | 28 |
*/ |
| 30 | 29 |
class Dynamic1D : Dynamic, Data1D |
| 31 | 30 |
{
|
| 32 |
private val vv: Vector<Static1D>
|
|
| 31 |
private val vv: MutableList<Static1D>
|
|
| 33 | 32 |
|
| 34 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | 34 |
// no array bounds checking! |
| ... | ... | |
| 126 | 125 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 127 | 126 |
// PUBLIC API |
| 128 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 129 |
constructor() : super(0,0.5f,1) { vv = Vector() }
|
|
| 128 |
constructor() : super(0,0.5f,1) { vv = mutableListOf() }
|
|
| 130 | 129 |
|
| 131 | 130 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 132 | 131 |
/** Constructor setting the speed of interpolation and the number of revolutions. |
| ... | ... | |
| 137 | 136 |
* @param duration number of milliseconds it takes to do one revolution. |
| 138 | 137 |
* @param count number of revolutions we will do. Count<=0 means 'infinite'. |
| 139 | 138 |
*/ |
| 140 |
constructor(duration: Int, count: Float) : super(duration,count,1) { vv = Vector() }
|
|
| 139 |
constructor(duration: Int, count: Float) : super(duration,count,1) { vv = mutableListOf() }
|
|
| 141 | 140 |
|
| 142 | 141 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 143 | 142 |
/** Returns the Static1D at index. |
| ... | ... | |
| 161 | 160 |
if (index in 0..<numPoints) |
| 162 | 161 |
{
|
| 163 | 162 |
val curr = vv.elementAt(index) |
| 164 |
|
|
| 165 |
if (curr!=null) |
|
| 166 |
{
|
|
| 167 |
curr.set0(x) |
|
| 168 |
cacheDirty = true |
|
| 169 |
} |
|
| 163 |
curr.set0(x) |
|
| 164 |
cacheDirty = true |
|
| 170 | 165 |
} |
| 171 | 166 |
} |
| 172 | 167 |
|
| ... | ... | |
| 267 | 262 |
when (numPoints) |
| 268 | 263 |
{
|
| 269 | 264 |
0, 1, 2 -> {}
|
| 270 |
3 -> vc!!.removeAllElements()
|
|
| 265 |
3 -> vc!!.clear()
|
|
| 271 | 266 |
else -> |
| 272 | 267 |
{
|
| 273 | 268 |
vc!!.removeAt(n) |
| ... | ... | |
| 294 | 289 |
{
|
| 295 | 290 |
if (index in 0..<numPoints) |
| 296 | 291 |
{
|
| 297 |
vv.removeElementAt(index)
|
|
| 292 |
vv.removeAt(index) |
|
| 298 | 293 |
vn?.removeAt(0) |
| 299 | 294 |
|
| 300 | 295 |
when (numPoints) |
| 301 | 296 |
{
|
| 302 | 297 |
0, 1, 2 -> {}
|
| 303 |
3 -> vc!!.removeAllElements()
|
|
| 304 |
else -> vc!!.removeElementAt(index)
|
|
| 298 |
3 -> vc!!.clear()
|
|
| 299 |
else -> vc!!.removeAt(index) |
|
| 305 | 300 |
} |
| 306 | 301 |
|
| 307 | 302 |
numPoints-- |
| ... | ... | |
| 319 | 314 |
fun removeAll() |
| 320 | 315 |
{
|
| 321 | 316 |
numPoints = 0 |
| 322 |
vv.removeAllElements()
|
|
| 323 |
vc!!.removeAllElements()
|
|
| 317 |
vv.clear()
|
|
| 318 |
vc!!.clear()
|
|
| 324 | 319 |
cacheDirty = false |
| 325 |
vn?.removeAllElements()
|
|
| 320 |
vn?.clear()
|
|
| 326 | 321 |
} |
| 327 | 322 |
|
| 328 | 323 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 339 | 334 |
{
|
| 340 | 335 |
if (vn==null) |
| 341 | 336 |
{
|
| 342 |
vn = Vector()
|
|
| 343 |
for (i in 0..<numPoints) vn!!.add(VectorNoise())
|
|
| 337 |
vn = mutableListOf()
|
|
| 338 |
repeat (numPoints) { vn!!.add(VectorNoise()) }
|
|
| 344 | 339 |
if (dimension>=2) mFactor = FloatArray(dimension-1) |
| 345 | 340 |
mNoise = FloatArray(dimension) |
| 346 | 341 |
} |
| src/main/java/org/distorted/library/type/Dynamic2D.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sqrt |
| 25 | 24 |
|
| 26 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 28 | 27 |
*/ |
| 29 | 28 |
class Dynamic2D : Dynamic, Data2D |
| 30 | 29 |
{
|
| 31 |
private val vv: Vector<Static2D>
|
|
| 30 |
private val vv: MutableList<Static2D>
|
|
| 32 | 31 |
|
| 33 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 33 |
// no array bounds checking! |
| ... | ... | |
| 158 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 159 | 158 |
// PUBLIC API |
| 160 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 161 |
constructor() : super(0, 0.5f, 2) { vv = Vector() }
|
|
| 160 |
constructor() : super(0, 0.5f, 2) { vv = mutableListOf() }
|
|
| 162 | 161 |
|
| 163 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 163 |
/** Constructor setting the speed of interpolation and the number of revolutions. |
| ... | ... | |
| 169 | 168 |
* @param duration number of milliseconds it takes to do one revolution. |
| 170 | 169 |
* @param count number of revolutions we will do. Count<=0 means 'infinite'. |
| 171 | 170 |
*/ |
| 172 |
constructor(duration: Int, count: Float) : super(duration, count, 2) { vv = Vector() }
|
|
| 171 |
constructor(duration: Int, count: Float) : super(duration, count, 2) { vv = mutableListOf() }
|
|
| 173 | 172 |
|
| 174 | 173 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 175 | 174 |
/** Returns the index'th Static2D. |
| ... | ... | |
| 196 | 195 |
if (index in 0..<numPoints) |
| 197 | 196 |
{
|
| 198 | 197 |
val curr = vv.elementAt(index) |
| 199 |
|
|
| 200 |
if (curr!=null) |
|
| 201 |
{
|
|
| 202 |
curr.set(x,y) |
|
| 203 |
cacheDirty = true |
|
| 204 |
} |
|
| 198 |
curr.set(x,y) |
|
| 199 |
cacheDirty = true |
|
| 205 | 200 |
} |
| 206 | 201 |
} |
| 207 | 202 |
|
| ... | ... | |
| 294 | 289 |
when (numPoints) |
| 295 | 290 |
{
|
| 296 | 291 |
0, 1, 2 -> {}
|
| 297 |
3 -> vc!!.removeAllElements()
|
|
| 292 |
3 -> vc!!.clear()
|
|
| 298 | 293 |
else -> vc!!.removeAt(n) |
| 299 | 294 |
} |
| 300 | 295 |
|
| ... | ... | |
| 319 | 314 |
{
|
| 320 | 315 |
if (index in 0..<numPoints) |
| 321 | 316 |
{
|
| 322 |
vv.removeElementAt(index)
|
|
| 317 |
vv.removeAt(index) |
|
| 323 | 318 |
vn?.removeAt(0) |
| 324 | 319 |
|
| 325 | 320 |
when (numPoints) |
| 326 | 321 |
{
|
| 327 | 322 |
0, 1, 2 -> {}
|
| 328 |
3 -> vc!!.removeAllElements()
|
|
| 329 |
else -> vc!!.removeElementAt(index)
|
|
| 323 |
3 -> vc!!.clear()
|
|
| 324 |
else -> vc!!.removeAt(index) |
|
| 330 | 325 |
} |
| 331 | 326 |
|
| 332 | 327 |
numPoints-- |
| ... | ... | |
| 344 | 339 |
fun removeAll() |
| 345 | 340 |
{
|
| 346 | 341 |
numPoints = 0 |
| 347 |
vv.removeAllElements()
|
|
| 348 |
vc!!.removeAllElements()
|
|
| 342 |
vv.clear()
|
|
| 343 |
vc!!.clear()
|
|
| 349 | 344 |
cacheDirty = false |
| 350 |
vn?.removeAllElements()
|
|
| 345 |
vn?.clear()
|
|
| 351 | 346 |
} |
| 352 | 347 |
|
| 353 | 348 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 364 | 359 |
{
|
| 365 | 360 |
if (vn==null) |
| 366 | 361 |
{
|
| 367 |
vn = Vector()
|
|
| 368 |
for (i in 0..<numPoints) vn!!.add(VectorNoise())
|
|
| 362 |
vn = mutableListOf()
|
|
| 363 |
repeat (numPoints) { vn!!.add(VectorNoise()) }
|
|
| 369 | 364 |
if (dimension >= 2) mFactor = FloatArray(dimension-1) |
| 370 | 365 |
mNoise = FloatArray(dimension) |
| 371 | 366 |
} |
| src/main/java/org/distorted/library/type/Dynamic3D.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sqrt |
| 25 | 24 |
|
| 26 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 28 | 27 |
*/ |
| 29 | 28 |
class Dynamic3D : Dynamic, Data3D |
| 30 | 29 |
{
|
| 31 |
private val vv: Vector<Static3D>
|
|
| 30 |
private val vv: MutableList<Static3D>
|
|
| 32 | 31 |
|
| 33 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 33 |
// no array bounds checking! |
| ... | ... | |
| 181 | 180 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 182 | 181 |
// PUBLIC API |
| 183 | 182 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 184 |
constructor() : super(0, 0.5f, 3) { vv = Vector() }
|
|
| 183 |
constructor() : super(0, 0.5f, 3) { vv = mutableListOf() }
|
|
| 185 | 184 |
|
| 186 | 185 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 187 | 186 |
/** Constructor setting the speed of interpolation and the number of revolutions. |
| ... | ... | |
| 192 | 191 |
* @param duration number of milliseconds it takes to do one revolution. |
| 193 | 192 |
* @param count number of revolutions we will do. Count<=0 means 'infinite'. |
| 194 | 193 |
*/ |
| 195 |
constructor(duration: Int, count: Float) : super(duration, count, 3) { vv = Vector() }
|
|
| 194 |
constructor(duration: Int, count: Float) : super(duration, count, 3) { vv = mutableListOf() }
|
|
| 196 | 195 |
|
| 197 | 196 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 198 | 197 |
/** Returns the index'th Static3D. |
| ... | ... | |
| 218 | 217 |
if (index in 0..<numPoints) |
| 219 | 218 |
{
|
| 220 | 219 |
val curr = vv.elementAt(index) |
| 221 |
|
|
| 222 |
if (curr != null) |
|
| 223 |
{
|
|
| 224 |
curr.set(x,y,z) |
|
| 225 |
cacheDirty = true |
|
| 226 |
} |
|
| 220 |
curr.set(x,y,z) |
|
| 221 |
cacheDirty = true |
|
| 227 | 222 |
} |
| 228 | 223 |
} |
| 229 | 224 |
|
| ... | ... | |
| 317 | 312 |
{
|
| 318 | 313 |
0, 1, 2 -> {}
|
| 319 | 314 |
3 -> {
|
| 320 |
vc!!.removeAllElements()
|
|
| 315 |
vc!!.clear()
|
|
| 321 | 316 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 322 | 317 |
} |
| 323 | 318 |
|
| ... | ... | |
| 345 | 340 |
{
|
| 346 | 341 |
if (index in 0..<numPoints) |
| 347 | 342 |
{
|
| 348 |
vv.removeElementAt(index)
|
|
| 343 |
vv.removeAt(index) |
|
| 349 | 344 |
vn?.removeAt(0) |
| 350 | 345 |
|
| 351 | 346 |
when (numPoints) |
| 352 | 347 |
{
|
| 353 | 348 |
0, 1, 2 -> {}
|
| 354 | 349 |
3 -> {
|
| 355 |
vc!!.removeAllElements()
|
|
| 350 |
vc!!.clear()
|
|
| 356 | 351 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 357 | 352 |
} |
| 358 | 353 |
|
| 359 |
else -> vc!!.removeElementAt(index)
|
|
| 354 |
else -> vc!!.removeAt(index) |
|
| 360 | 355 |
} |
| 361 | 356 |
|
| 362 | 357 |
numPoints-- |
| ... | ... | |
| 374 | 369 |
fun removeAll() |
| 375 | 370 |
{
|
| 376 | 371 |
numPoints = 0 |
| 377 |
vv.removeAllElements()
|
|
| 378 |
vc!!.removeAllElements()
|
|
| 372 |
vv.clear()
|
|
| 373 |
vc!!.clear()
|
|
| 379 | 374 |
cacheDirty = false |
| 380 |
vn?.removeAllElements()
|
|
| 375 |
vn?.clear()
|
|
| 381 | 376 |
} |
| 382 | 377 |
|
| 383 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 394 | 389 |
{
|
| 395 | 390 |
if (vn == null) |
| 396 | 391 |
{
|
| 397 |
vn = Vector()
|
|
| 398 |
for (i in 0..<numPoints) vn!!.add(VectorNoise())
|
|
| 392 |
vn = mutableListOf()
|
|
| 393 |
repeat (numPoints) { vn!!.add(VectorNoise()) }
|
|
| 399 | 394 |
if (dimension>=2) mFactor = FloatArray(dimension-1) |
| 400 | 395 |
mNoise = FloatArray(dimension) |
| 401 | 396 |
} |
| src/main/java/org/distorted/library/type/Dynamic4D.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sqrt |
| 25 | 24 |
|
| 26 | 25 |
////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 28 | 27 |
*/ |
| 29 | 28 |
class Dynamic4D : Dynamic, Data4D |
| 30 | 29 |
{
|
| 31 |
private val vv: Vector<Static4D>
|
|
| 30 |
private val vv: MutableList<Static4D>
|
|
| 32 | 31 |
|
| 33 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 33 |
// no array bounds checking! |
| ... | ... | |
| 204 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 205 | 204 |
// PUBLIC API |
| 206 | 205 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 207 |
constructor() : super(0, 0.5f, 4) { vv = Vector() }
|
|
| 206 |
constructor() : super(0, 0.5f, 4) { vv = mutableListOf() }
|
|
| 208 | 207 |
|
| 209 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 210 | 209 |
/** Constructor setting the speed of interpolation and the number of revolutions. |
| ... | ... | |
| 215 | 214 |
* @param duration number of milliseconds it takes to do one revolution. |
| 216 | 215 |
* @param count number of revolutions we will do. Count<=0 means 'infinite'. |
| 217 | 216 |
*/ |
| 218 |
constructor(duration: Int, count: Float) : super(duration,count,4) { vv = Vector() }
|
|
| 217 |
constructor(duration: Int, count: Float) : super(duration,count,4) { vv = mutableListOf() }
|
|
| 219 | 218 |
|
| 220 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 221 | 220 |
/** Returns the index'th Static4D. |
| ... | ... | |
| 241 | 240 |
if (index in 0..<numPoints) |
| 242 | 241 |
{
|
| 243 | 242 |
val curr = vv.elementAt(index) |
| 244 |
|
|
| 245 |
if (curr!=null) |
|
| 246 |
{
|
|
| 247 |
curr.set(x,y,z,w) |
|
| 248 |
cacheDirty = true |
|
| 249 |
} |
|
| 243 |
curr.set(x,y,z,w) |
|
| 244 |
cacheDirty = true |
|
| 250 | 245 |
} |
| 251 | 246 |
} |
| 252 | 247 |
|
| ... | ... | |
| 338 | 333 |
{
|
| 339 | 334 |
0, 1, 2 -> {}
|
| 340 | 335 |
3 -> {
|
| 341 |
vc!!.removeAllElements()
|
|
| 336 |
vc!!.clear()
|
|
| 342 | 337 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 343 | 338 |
} |
| 344 | 339 |
else -> vc!!.removeAt(n) |
| ... | ... | |
| 365 | 360 |
{
|
| 366 | 361 |
if (index in 0..<numPoints) |
| 367 | 362 |
{
|
| 368 |
vv.removeElementAt(index)
|
|
| 363 |
vv.removeAt(index) |
|
| 369 | 364 |
vn?.removeAt(0) |
| 370 | 365 |
|
| 371 | 366 |
when (numPoints) |
| 372 | 367 |
{
|
| 373 | 368 |
0, 1, 2 -> {}
|
| 374 | 369 |
3 -> {
|
| 375 |
vc!!.removeAllElements()
|
|
| 370 |
vc!!.clear()
|
|
| 376 | 371 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 377 | 372 |
} |
| 378 | 373 |
|
| 379 |
else -> vc!!.removeElementAt(index)
|
|
| 374 |
else -> vc!!.removeAt(index) |
|
| 380 | 375 |
} |
| 381 | 376 |
|
| 382 | 377 |
numPoints-- |
| ... | ... | |
| 394 | 389 |
fun removeAll() |
| 395 | 390 |
{
|
| 396 | 391 |
numPoints = 0 |
| 397 |
vv.removeAllElements()
|
|
| 398 |
vc!!.removeAllElements()
|
|
| 392 |
vv.clear()
|
|
| 393 |
vc!!.clear()
|
|
| 399 | 394 |
cacheDirty = false |
| 400 |
vn?.removeAllElements()
|
|
| 395 |
vn?.clear()
|
|
| 401 | 396 |
} |
| 402 | 397 |
|
| 403 | 398 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 414 | 409 |
{
|
| 415 | 410 |
if (vn==null) |
| 416 | 411 |
{
|
| 417 |
vn = Vector()
|
|
| 418 |
for (i in 0..<numPoints) vn!!.add(VectorNoise())
|
|
| 412 |
vn = mutableListOf()
|
|
| 413 |
repeat (numPoints) { vn!!.add(VectorNoise()) }
|
|
| 419 | 414 |
if (dimension >= 2) mFactor = FloatArray(dimension-1) |
| 420 | 415 |
mNoise = FloatArray(dimension) |
| 421 | 416 |
} |
| src/main/java/org/distorted/library/type/Dynamic5D.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sqrt |
| 25 | 24 |
|
| 26 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 28 | 27 |
*/ |
| 29 | 28 |
class Dynamic5D : Dynamic, Data5D |
| 30 | 29 |
{
|
| 31 |
private val vv: Vector<Static5D>
|
|
| 30 |
private val vv: MutableList<Static5D>
|
|
| 32 | 31 |
|
| 33 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 33 |
// no array bounds checking! |
| ... | ... | |
| 227 | 226 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 228 | 227 |
// PUBLIC API |
| 229 | 228 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 230 |
constructor() : super(0, 0.5f, 5) { vv = Vector() }
|
|
| 229 |
constructor() : super(0, 0.5f, 5) { vv = mutableListOf() }
|
|
| 231 | 230 |
|
| 232 | 231 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 233 | 232 |
/** Constructor setting the speed of interpolation and the number of revolutions. |
| ... | ... | |
| 238 | 237 |
* @param duration number of milliseconds it takes to do one revolution. |
| 239 | 238 |
* @param count number of revolutions we will do. Count<=0 means 'infinite'. |
| 240 | 239 |
*/ |
| 241 |
constructor(duration: Int, count: Float) : super(duration, count, 5) { vv = Vector() }
|
|
| 240 |
constructor(duration: Int, count: Float) : super(duration, count, 5) { vv = mutableListOf() }
|
|
| 242 | 241 |
|
| 243 | 242 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| 244 | 243 |
/** Returns the index'th Static5D. |
| ... | ... | |
| 264 | 263 |
if (index in 0..<numPoints) |
| 265 | 264 |
{
|
| 266 | 265 |
val curr = vv.elementAt(index) |
| 267 |
|
|
| 268 |
if (curr!=null) |
|
| 269 |
{
|
|
| 270 |
curr.set(x,y,z,w,v) |
|
| 271 |
cacheDirty = true |
|
| 272 |
} |
|
| 266 |
curr.set(x,y,z,w,v) |
|
| 267 |
cacheDirty = true |
|
| 273 | 268 |
} |
| 274 | 269 |
} |
| 275 | 270 |
|
| ... | ... | |
| 361 | 356 |
{
|
| 362 | 357 |
0, 1, 2 -> {}
|
| 363 | 358 |
3 -> {
|
| 364 |
vc!!.removeAllElements()
|
|
| 359 |
vc!!.clear()
|
|
| 365 | 360 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 366 | 361 |
} |
| 367 | 362 |
else -> vc!!.removeAt(n) |
| ... | ... | |
| 388 | 383 |
{
|
| 389 | 384 |
if (index in 0..<numPoints) |
| 390 | 385 |
{
|
| 391 |
vv.removeElementAt(index)
|
|
| 386 |
vv.removeAt(index) |
|
| 392 | 387 |
vn?.removeAt(0) |
| 393 | 388 |
|
| 394 | 389 |
when (numPoints) |
| 395 | 390 |
{
|
| 396 | 391 |
0, 1, 2 -> {}
|
| 397 | 392 |
3 -> {
|
| 398 |
vc!!.removeAllElements()
|
|
| 393 |
vc!!.clear()
|
|
| 399 | 394 |
computeOrthonormalBase2(vv.elementAt(0), vv.elementAt(1)) |
| 400 | 395 |
} |
| 401 |
else -> vc!!.removeElementAt(index)
|
|
| 396 |
else -> vc!!.removeAt(index) |
|
| 402 | 397 |
} |
| 403 | 398 |
|
| 404 | 399 |
numPoints-- |
| ... | ... | |
| 416 | 411 |
fun removeAll() |
| 417 | 412 |
{
|
| 418 | 413 |
numPoints = 0 |
| 419 |
vv.removeAllElements()
|
|
| 420 |
vc!!.removeAllElements()
|
|
| 414 |
vv.clear()
|
|
| 415 |
vc!!.clear()
|
|
| 421 | 416 |
cacheDirty = false |
| 422 |
vn?.removeAllElements()
|
|
| 417 |
vn?.clear()
|
|
| 423 | 418 |
} |
| 424 | 419 |
|
| 425 | 420 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 436 | 431 |
{
|
| 437 | 432 |
if (vn == null) |
| 438 | 433 |
{
|
| 439 |
vn = Vector()
|
|
| 440 |
for (i in 0..<numPoints) vn!!.add(VectorNoise())
|
|
| 434 |
vn = mutableListOf()
|
|
| 435 |
repeat (numPoints) { vn!!.add(VectorNoise()) }
|
|
| 441 | 436 |
if (dimension>=2) mFactor = FloatArray(dimension-1) |
| 442 | 437 |
mNoise = FloatArray(dimension) |
| 443 | 438 |
} |
| src/main/java/org/distorted/library/type/DynamicQuat.kt | ||
|---|---|---|
| 20 | 20 |
|
| 21 | 21 |
package org.distorted.library.type |
| 22 | 22 |
|
| 23 |
import java.util.Vector |
|
| 24 | 23 |
import kotlin.math.sin |
| 25 | 24 |
import kotlin.math.sqrt |
| 26 | 25 |
|
| ... | ... | |
| 42 | 41 |
// |
| 43 | 42 |
// (vx,vy,vz,vw) is the original vector from vv (copied here so when interpolating we can see if it is |
| 44 | 43 |
// still valid and if not - rebuild the Cache. |
| 45 |
private inner class VectorCacheQuat
|
|
| 44 |
private class VectorCacheQuat
|
|
| 46 | 45 |
{
|
| 47 | 46 |
var omega: Float = 0f |
| 48 | 47 |
var sinOmega: Float = 0f |
| ... | ... | |
| 53 | 52 |
var vw: Float = 0f |
| 54 | 53 |
} |
| 55 | 54 |
|
| 56 |
private var cc: Vector<VectorCacheQuat> = Vector<VectorCacheQuat>()
|
|
| 57 |
private val vv = Vector<Static4D>()
|
|
| 55 |
private var cc: MutableList<VectorCacheQuat> = mutableListOf()
|
|
| 56 |
private val vv: MutableList<Static4D> = mutableListOf()
|
|
| 58 | 57 |
|
| 59 | 58 |
companion object |
| 60 | 59 |
{
|
| ... | ... | |
| 154 | 153 |
if (index in 0..<numPoints) |
| 155 | 154 |
{
|
| 156 | 155 |
val curr = vv.elementAt(index) |
| 157 |
|
|
| 158 |
if (curr!=null) |
|
| 159 |
{
|
|
| 160 |
curr.set(x,y,z,w) |
|
| 161 |
cacheDirty = true |
|
| 162 |
} |
|
| 156 |
curr.set(x,y,z,w) |
|
| 157 |
cacheDirty = true |
|
| 163 | 158 |
} |
| 164 | 159 |
} |
| 165 | 160 |
|
| ... | ... | |
| 216 | 211 |
cc.add(VectorCacheQuat()) |
| 217 | 212 |
cc.add(VectorCacheQuat()) |
| 218 | 213 |
} |
| 219 |
else -> cc.add(index,VectorCacheQuat()) |
|
| 214 |
else -> cc.add(index, VectorCacheQuat())
|
|
| 220 | 215 |
} |
| 221 | 216 |
|
| 222 | 217 |
numPoints++ |
| ... | ... | |
| 243 | 238 |
when (numPoints) |
| 244 | 239 |
{
|
| 245 | 240 |
0, 1 -> {}
|
| 246 |
2 -> cc.removeAllElements()
|
|
| 241 |
2 -> cc.clear()
|
|
| 247 | 242 |
else -> cc.removeAt(n) |
| 248 | 243 |
} |
| 249 | 244 |
|
| ... | ... | |
| 268 | 263 |
{
|
| 269 | 264 |
if (index in 0..<numPoints) |
| 270 | 265 |
{
|
| 271 |
vv.removeElementAt(index)
|
|
| 266 |
vv.removeAt(index) |
|
| 272 | 267 |
|
| 273 | 268 |
when (numPoints) |
| 274 | 269 |
{
|
| 275 | 270 |
0, 1 -> {}
|
| 276 |
2 -> cc.removeAllElements()
|
|
| 277 |
else -> cc.removeElementAt(index)
|
|
| 271 |
2 -> cc.clear()
|
|
| 272 |
else -> cc.removeAt(index) |
|
| 278 | 273 |
} |
| 279 | 274 |
|
| 280 | 275 |
numPoints-- |
| ... | ... | |
| 292 | 287 |
fun removeAll() |
| 293 | 288 |
{
|
| 294 | 289 |
numPoints = 0 |
| 295 |
vv.removeAllElements()
|
|
| 296 |
cc.removeAllElements()
|
|
| 290 |
vv.clear()
|
|
| 291 |
cc.clear()
|
|
| 297 | 292 |
cacheDirty = false |
| 298 | 293 |
} |
| 299 | 294 |
|
Also available in: Unified diff
Completely remove any mention of java.util