| 1 |
/*======================================================================*//** |
|---|
| 2 |
* |
|---|
| 3 |
* Utils for ActionScript 3.0 |
|---|
| 4 |
* |
|---|
| 5 |
* @author Copyright (c) 2007 Spark project. |
|---|
| 6 |
* @version 1.0.0 |
|---|
| 7 |
* |
|---|
| 8 |
* @see http://utils.libspark.org/ |
|---|
| 9 |
* @see http://www.libspark.org/ |
|---|
| 10 |
* |
|---|
| 11 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 12 |
* you may not use this file except in compliance with the License. |
|---|
| 13 |
* You may obtain a copy of the License at |
|---|
| 14 |
* |
|---|
| 15 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 16 |
* |
|---|
| 17 |
* Unless required by applicable law or agreed to in writing, software |
|---|
| 18 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 19 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|---|
| 20 |
* either express or implied. See the License for the specific language |
|---|
| 21 |
* governing permissions and limitations under the License. |
|---|
| 22 |
* |
|---|
| 23 |
*//*=======================================================================*/ |
|---|
| 24 |
package org.libspark.utils { |
|---|
| 25 |
import flash.errors.IllegalOperationError; |
|---|
| 26 |
import flash.geom.Point; |
|---|
| 27 |
|
|---|
| 28 |
/** |
|---|
| 29 |
* 基本的な計算を補うためのユーティリティクラスです |
|---|
| 30 |
*/ |
|---|
| 31 |
public class MathUtil { |
|---|
| 32 |
|
|---|
| 33 |
/*======================================================================*//** |
|---|
| 34 |
* @private |
|---|
| 35 |
*//*=======================================================================*/ |
|---|
| 36 |
public function MathUtil() { |
|---|
| 37 |
throw new IllegalOperationError( "MathUtil クラスはインスタンスを生成できません。" ); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
/*======================================================================*//** |
|---|
| 45 |
* 数値を指定された周期内に収めて返します。 |
|---|
| 46 |
* @author taka:nium |
|---|
| 47 |
* @param number 周期内に収めたい数値です。 |
|---|
| 48 |
* @param cycle 周期となる数値です。 |
|---|
| 49 |
* @return 変換後の数値です。 |
|---|
| 50 |
*//*=======================================================================*/ |
|---|
| 51 |
static public function cycle( number:Number, cycle:Number ):Number { |
|---|
| 52 |
return ( number % cycle + cycle ) % cycle; |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
/*======================================================================*//** |
|---|
| 56 |
* 範囲内に適合する値を返します。 |
|---|
| 57 |
* @author taka:nium |
|---|
| 58 |
* @param number 範囲内に適合させたい数値です。 |
|---|
| 59 |
* @param min 範囲の最小値となる数値です。 |
|---|
| 60 |
* @param max 範囲の最大値となる数値です。 |
|---|
| 61 |
* @return 変換後の数値です。 |
|---|
| 62 |
*//*=======================================================================*/ |
|---|
| 63 |
static public function range( number:Number, min:Number, max:Number ):Number { |
|---|
| 64 |
// min の方が max よりも大きい場合に入れ替える |
|---|
| 65 |
if ( min > max ) { |
|---|
| 66 |
var temp:Number = min; |
|---|
| 67 |
min = max; |
|---|
| 68 |
max = temp; |
|---|
| 69 |
} |
|---|
| 70 |
return Math.max( min, Math.min( number, max ) ); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
/*======================================================================*//** |
|---|
| 74 |
* 分母が 0 の場合に 0 となるパーセント値を返します。 |
|---|
| 75 |
* @author taka:nium |
|---|
| 76 |
* @param numerator 分母となる数値です。 |
|---|
| 77 |
* @param denominator 分子となる数値です。 |
|---|
| 78 |
* @return 変換後の数値です。 |
|---|
| 79 |
*//*=======================================================================*/ |
|---|
| 80 |
static public function percent( numerator:Number, denominator:Number ):Number { |
|---|
| 81 |
if ( denominator == 0 ) { return 0; } |
|---|
| 82 |
return numerator / denominator * 100; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
/*======================================================================*//** |
|---|
| 86 |
* 縦列と横列からテーブル状の座標を格納した Point オブジェクト配列を作成します。 |
|---|
| 87 |
* @author taka:nium |
|---|
| 88 |
* @param rows 作成する格子の縦区切り数です。 |
|---|
| 89 |
* @param cols 作成する格子の横区切り数です。 |
|---|
| 90 |
* @return 作成した格子データ配列です。 |
|---|
| 91 |
*//*=======================================================================*/ |
|---|
| 92 |
static public function getTable( rows:uint, cols:uint ):Array { |
|---|
| 93 |
var table:Array = new Array(); |
|---|
| 94 |
for ( var i:int = 0; i < rows; i++ ) { |
|---|
| 95 |
for ( var ii:int = 0; ii < cols; ii++ ) { |
|---|
| 96 |
table.push( new Point( ii, i ) ); |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
return table; |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
/*======================================================================*//** |
|---|
| 103 |
* ランダムで +1 もしくは -1 を返します。 |
|---|
| 104 |
* @author taka:nium |
|---|
| 105 |
* @return +1 もしくは -1 の数値です。 |
|---|
| 106 |
*//*=======================================================================*/ |
|---|
| 107 |
static public function getCoin():int { |
|---|
| 108 |
return ( Math.random() < 0.5 ) ? 1 : -1; |
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
/** |
|---|
| 113 |
* 引数の値が正数の場合のみ、その数値を返し、負数の場合は0を返します. |
|---|
| 114 |
* |
|---|
| 115 |
* @param n 数値 |
|---|
| 116 |
* @return 正数(0以上の数値) |
|---|
| 117 |
* @author michi at seyself.com |
|---|
| 118 |
*/ |
|---|
| 119 |
public static function positive( n:Number ):Number |
|---|
| 120 |
{ |
|---|
| 121 |
if(n>0) return n; |
|---|
| 122 |
return 0; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
/** |
|---|
| 126 |
* 引数の値が負数の場合のみ数値を返し、正数の場合は0を返します. |
|---|
| 127 |
* |
|---|
| 128 |
* @param n 数値 |
|---|
| 129 |
* @return 負数(0以下の数値) |
|---|
| 130 |
* @author michi at seyself.com |
|---|
| 131 |
*/ |
|---|
| 132 |
public static function negative( n:Number ):Number |
|---|
| 133 |
{ |
|---|
| 134 |
if(n<0) return n; |
|---|
| 135 |
return 0; |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
/** |
|---|
| 139 |
* 引数が正数の場合は+1を、負数の場合は-1、その他の場合は0を返します. |
|---|
| 140 |
* |
|---|
| 141 |
* @param n 数値 |
|---|
| 142 |
* @return 1 もしくは -1 、0 |
|---|
| 143 |
* @author michi at seyself.com |
|---|
| 144 |
*/ |
|---|
| 145 |
public static function judgment( n:Number ):Number |
|---|
| 146 |
{ |
|---|
| 147 |
if(n>0) return 1; |
|---|
| 148 |
if(n<0) return -1; |
|---|
| 149 |
return 0; |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
/** |
|---|
| 153 |
* 引数から約数を求めて配列で返します. |
|---|
| 154 |
* |
|---|
| 155 |
* @param n 数値 |
|---|
| 156 |
* @return 約数の配列 |
|---|
| 157 |
* @author michi at seyself.com |
|---|
| 158 |
*/ |
|---|
| 159 |
public static function measure( param:Number ):Array |
|---|
| 160 |
{ |
|---|
| 161 |
var m:Number = param; |
|---|
| 162 |
var res:Array = [1,param]; |
|---|
| 163 |
var maxcount:Number = Math.floor(Math.sqrt(m)+1); |
|---|
| 164 |
for(var i:uint=2;i<maxcount ;i++){ |
|---|
| 165 |
if(param%i==0){ |
|---|
| 166 |
var s:Number = 0; |
|---|
| 167 |
var e:Number = 0; |
|---|
| 168 |
for(var k:uint=0;k<res.length;k++){ |
|---|
| 169 |
if( res[k] ==i ) s++; |
|---|
| 170 |
if( res[k] ==param/i ) e++; |
|---|
| 171 |
} |
|---|
| 172 |
if(s==0) res.push(i); |
|---|
| 173 |
if(param/i!=i && e==0) res.push(param/i); |
|---|
| 174 |
} |
|---|
| 175 |
} |
|---|
| 176 |
return res.sort( Array.NUMERIC ); |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
/** |
|---|
| 180 |
* 小数点以下 指定桁で四捨五入します. |
|---|
| 181 |
* |
|---|
| 182 |
* @param param 数値 |
|---|
| 183 |
* @param len 小数点以下の桁数 |
|---|
| 184 |
* @return 小数点以下 指定桁で四捨五入した値 |
|---|
| 185 |
* @author michi at seyself.com |
|---|
| 186 |
*/ |
|---|
| 187 |
public static function round( param:Number , len:uint ):Number |
|---|
| 188 |
{ |
|---|
| 189 |
var _mgn:uint = 1; |
|---|
| 190 |
for(var i:uint=0;i<len;i++) _mgn*=10; |
|---|
| 191 |
return Math.round(param*_mgn)/_mgn; |
|---|
| 192 |
} |
|---|
| 193 |
|
|---|
| 194 |
/** |
|---|
| 195 |
* 小数点以下 指定桁数で切り捨てた値を返します. |
|---|
| 196 |
* |
|---|
| 197 |
* @param param 数値 |
|---|
| 198 |
* @param len 小数点以下の桁数 |
|---|
| 199 |
* @return 数点以下 指定桁数で切り捨てた値 |
|---|
| 200 |
* @author michi at seyself.com |
|---|
| 201 |
*/ |
|---|
| 202 |
public static function floor( param:Number , len:uint ):Number |
|---|
| 203 |
{ |
|---|
| 204 |
var _mgn:uint = 1; |
|---|
| 205 |
for(var i:uint=0;i<len;i++) _mgn*=10; |
|---|
| 206 |
return Math.floor(param*_mgn)/_mgn; |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
/** |
|---|
| 210 |
* 指定された数値の立方根を計算して返します。 |
|---|
| 211 |
* @param x 立方根を求めたい数値 |
|---|
| 212 |
* @return x の立方根 |
|---|
| 213 |
* @author michi at seyself.com |
|---|
| 214 |
*/ |
|---|
| 215 |
public static function cuberoot( x:Number ):Number |
|---|
| 216 |
{ |
|---|
| 217 |
var s:Number, t:Number, prev:Number; |
|---|
| 218 |
var posi:int; |
|---|
| 219 |
if(x==0) return 0; |
|---|
| 220 |
if(x>0) posi=1; else { posi=0; x= -x; } |
|---|
| 221 |
if(x>1) s=x; else s=1; |
|---|
| 222 |
do{ |
|---|
| 223 |
prev=s; t=s*s; s+=(x-t*s)/(2*t+x/s); |
|---|
| 224 |
} while(s<prev); |
|---|
| 225 |
if( posi ) return prev; |
|---|
| 226 |
else return -prev; |
|---|
| 227 |
} |
|---|
| 228 |
|
|---|
| 229 |
/** |
|---|
| 230 |
* 渡された正数の値から正と負の値を交互に変換した値を返します. |
|---|
| 231 |
* |
|---|
| 232 |
* @param n 正数の値 |
|---|
| 233 |
* @return 引数が奇数なら負数、偶数なら正数が返ります |
|---|
| 234 |
* @author michi at seyself.com |
|---|
| 235 |
*/ |
|---|
| 236 |
public static function xcount( i:uint ):Number |
|---|
| 237 |
{ |
|---|
| 238 |
var a:Number = Math.floor(i/2); |
|---|
| 239 |
if(i%2>0) a = -(a+1); |
|---|
| 240 |
a *= -1; |
|---|
| 241 |
return a; |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
/** |
|---|
| 245 |
* 渡された引数の合計値を返します. |
|---|
| 246 |
* 配列を使用する場合はapplyを使用してください. |
|---|
| 247 |
* |
|---|
| 248 |
* @param ...numbers 数値 |
|---|
| 249 |
* @return 引数の合計値 |
|---|
| 250 |
* @author michi at seyself.com |
|---|
| 251 |
*/ |
|---|
| 252 |
public static function sum( ...numbers ):Number |
|---|
| 253 |
{ |
|---|
| 254 |
var a:Number = 0; |
|---|
| 255 |
var leng:uint = numbers.length; |
|---|
| 256 |
for(var i:uint=0;i<leng;i++) a+=numbers[i]; |
|---|
| 257 |
return a; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
/** |
|---|
| 261 |
* 渡された引数の平均値を返します. |
|---|
| 262 |
* 配列を使用する場合はapplyを使用してください. |
|---|
| 263 |
* |
|---|
| 264 |
* @param ...numbers 数値 |
|---|
| 265 |
* @return 引数の平均値 |
|---|
| 266 |
* @author michi at seyself.com |
|---|
| 267 |
*/ |
|---|
| 268 |
public static function average( ...numbers ):Number |
|---|
| 269 |
{ |
|---|
| 270 |
return sum.apply(null,numbers)/numbers.length; |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
/** |
|---|
| 274 |
* -1.0 から 1.0 の間の乱数を生成します. |
|---|
| 275 |
* |
|---|
| 276 |
* @return 乱数 |
|---|
| 277 |
* @author michi at seyself.com |
|---|
| 278 |
*/ |
|---|
| 279 |
public static function random():Number |
|---|
| 280 |
{ |
|---|
| 281 |
return Math.random() * 2 - 1; |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
/** |
|---|
| 285 |
* -1.0 から 1.0 の間の偏向乱数を生成します. |
|---|
| 286 |
* |
|---|
| 287 |
* @param interation 数値が多いほど乱数値は0に近づきます |
|---|
| 288 |
* @return 乱数 |
|---|
| 289 |
* @author michi at seyself.com |
|---|
| 290 |
*/ |
|---|
| 291 |
public static function biasedRandom(interation:uint = 2):Number |
|---|
| 292 |
{ |
|---|
| 293 |
var n:Number = 0; |
|---|
| 294 |
for (var i:int = 0; i < interation; i++ ) n += random(); |
|---|
| 295 |
return n / interation; |
|---|
| 296 |
} |
|---|
| 297 |
|
|---|
| 298 |
/** |
|---|
| 299 |
* 0.0 から 1.0 の間の疑似乱数を生成します.Perlin ノイズとはまったく関係ないです。 |
|---|
| 300 |
* (注: あまり極端な値を設定すると正しく動作しないかもしれません。) |
|---|
| 301 |
* |
|---|
| 302 |
* @param i インデックス値 |
|---|
| 303 |
* @param seed 乱数の定義値 |
|---|
| 304 |
* @return 数値 |
|---|
| 305 |
* @author michi at seyself.com |
|---|
| 306 |
*/ |
|---|
| 307 |
public static function noise( i:uint, seed:Number=0.0 ):Number |
|---|
| 308 |
{ |
|---|
| 309 |
seed %= 0xFFF; |
|---|
| 310 |
i %= 0x7FF; |
|---|
| 311 |
var P:Number = 3.14159265358979 * ( seed + 0.5 ); |
|---|
| 312 |
var t:Number = 173*i*i*i+13577 % 3568927; |
|---|
| 313 |
var r:Number = (i*2.71828182845905+t)*P%1; |
|---|
| 314 |
return r; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
/** |
|---|
| 318 |
* 渡されたラジアン値を角度に変換します. |
|---|
| 319 |
* |
|---|
| 320 |
* @param angle ラジアン |
|---|
| 321 |
* @return 角度 |
|---|
| 322 |
* @author michi at seyself.com |
|---|
| 323 |
*/ |
|---|
| 324 |
public static function degrees(angle:Number):Number |
|---|
| 325 |
{ |
|---|
| 326 |
return angle / Math.PI * 180; |
|---|
| 327 |
} |
|---|
| 328 |
|
|---|
| 329 |
/** |
|---|
| 330 |
* 渡された角度をラジアン値に変換します. |
|---|
| 331 |
* |
|---|
| 332 |
* @param angle 角度 |
|---|
| 333 |
* @return ラジアン |
|---|
| 334 |
* @author michi at seyself.com |
|---|
| 335 |
*/ |
|---|
| 336 |
public static function radians(angle:Number):Number |
|---|
| 337 |
{ |
|---|
| 338 |
return angle / 180 * Math.PI; |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
/** |
|---|
| 342 |
* 2つの角( angle1 から angle2 )の内角の値を調べます |
|---|
| 343 |
* |
|---|
| 344 |
* @param angle1 角度 (ラジアン単位) |
|---|
| 345 |
* @param angle2 角度 (ラジアン単位) |
|---|
| 346 |
* @return 2つの角度の内角距離 |
|---|
| 347 |
* @author michi at seyself.com |
|---|
| 348 |
*/ |
|---|
| 349 |
public static function interiorAngle(angle1:Number, angle2:Number):Number |
|---|
| 350 |
{ |
|---|
| 351 |
var a:Number = angle2 - angle1; |
|---|
| 352 |
return Math.atan2(Math.sin(a), Math.cos(a)); |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
/** |
|---|
| 356 |
* 2乗した数値を返します |
|---|
| 357 |
* @param value 数値 |
|---|
| 358 |
* @return 2乗した数値 |
|---|
| 359 |
* @author michi at seyself.com |
|---|
| 360 |
*/ |
|---|
| 361 |
public static function sq(value:Number):Number |
|---|
| 362 |
{ |
|---|
| 363 |
return value * value; |
|---|
| 364 |
} |
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
public static function magnitude(x:Number, y:Number, z:Number=0):Number |
|---|
| 368 |
{ |
|---|
| 369 |
return Math.sqrt(x * x + y * y + z * z); |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
/** |
|---|
| 375 |
* (x1,y1)と(x2,y2)の距離を求めます |
|---|
| 376 |
* @param x1 |
|---|
| 377 |
* @param y1 |
|---|
| 378 |
* @param x2 |
|---|
| 379 |
* @param y2 |
|---|
| 380 |
* @return |
|---|
| 381 |
* @author michi at seyself.com |
|---|
| 382 |
*/ |
|---|
| 383 |
public static function dist(x1:Number, y1:Number, x2:Number, y2:Number):Number |
|---|
| 384 |
{ |
|---|
| 385 |
var nx:Number = x2 - x1; |
|---|
| 386 |
var ny:Number = y2 - y1; |
|---|
| 387 |
return Math.sqrt(nx * nx + ny * ny); |
|---|
| 388 |
} |
|---|
| 389 |
|
|---|
| 390 |
/** |
|---|
| 391 |
* (x1,y1,z1)と(x2,y2,z2)の距離を求めます |
|---|
| 392 |
* @param x1 |
|---|
| 393 |
* @param y1 |
|---|
| 394 |
* @param z1 |
|---|
| 395 |
* @param x2 |
|---|
| 396 |
* @param y2 |
|---|
| 397 |
* @param z2 |
|---|
| 398 |
* @return |
|---|
| 399 |
* @author michi at seyself.com |
|---|
| 400 |
*/ |
|---|
| 401 |
public static function dist3(x1:Number, y1:Number, z1:Number, x2:Number, y2:Number, z2:Number):Number |
|---|
| 402 |
{ |
|---|
| 403 |
var nx:Number = x2 - x1; |
|---|
| 404 |
var ny:Number = y2 - y1; |
|---|
| 405 |
var nz:Number = z2 - z1; |
|---|
| 406 |
return Math.sqrt(nx * nx + ny * ny + nz * nz); |
|---|
| 407 |
} |
|---|
| 408 |
|
|---|
| 409 |
/** |
|---|
| 410 |
* 標準値を求めます |
|---|
| 411 |
* @param value |
|---|
| 412 |
* @param low |
|---|
| 413 |
* @param high |
|---|
| 414 |
* @return |
|---|
| 415 |
* @author michi at seyself.com |
|---|
| 416 |
*/ |
|---|
| 417 |
public static function norm(value:Number, low:Number, high:Number):Number |
|---|
| 418 |
{ |
|---|
| 419 |
return (value - low) / (high - low); |
|---|
| 420 |
} |
|---|
| 421 |
|
|---|
| 422 |
/** |
|---|
| 423 |
* 2つの数値 (value1,value2) の間 (amt) の数値を求めます |
|---|
| 424 |
* @param value1 |
|---|
| 425 |
* @param value2 |
|---|
| 426 |
* @param amt |
|---|
| 427 |
* @return |
|---|
| 428 |
* @author michi at seyself.com |
|---|
| 429 |
*/ |
|---|
| 430 |
public static function lerp(value1:Number, value2:Number, amt:Number):Number |
|---|
| 431 |
{ |
|---|
| 432 |
return value1 + (value2-value1) * amt; |
|---|
| 433 |
} |
|---|
| 434 |
|
|---|
| 435 |
/** |
|---|
| 436 |
* |
|---|
| 437 |
* @param value |
|---|
| 438 |
* @param low1 |
|---|
| 439 |
* @param high1 |
|---|
| 440 |
* @param low2 |
|---|
| 441 |
* @param high2 |
|---|
| 442 |
* @return |
|---|
| 443 |
* @author michi at seyself.com |
|---|
| 444 |
*/ |
|---|
| 445 |
public static function map(value:Number, low1:Number, high1:Number, low2:Number, high2:Number):Number |
|---|
| 446 |
{ |
|---|
| 447 |
return (value - low1) / (high1 - low1) * (high2 - low2) + low2; |
|---|
| 448 |
} |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
/*======================================================================*//** |
|---|
| 454 |
* 回転砲台のアルゴリズム |
|---|
| 455 |
* 現在角度から目標角度に到達するために必要となる最短の回転角を返します |
|---|
| 456 |
* 角度は時計回りを正の方向とします |
|---|
| 457 |
* @author alumican |
|---|
| 458 |
* @param current 現在の角度, 単位[rad] |
|---|
| 459 |
* @param target 目標の角度, 単位[rad] |
|---|
| 460 |
* @return 目標へ到達するための差分角度, 単位[rad], 範囲(-2π,2π) |
|---|
| 461 |
*//*=======================================================================*/ |
|---|
| 462 |
public static function earliestRotation(current:Number, target:Number):Number { |
|---|
| 463 |
var pi2:Number = 2 * Math.PI; |
|---|
| 464 |
var d:Number = target % pi2 - current % pi2; |
|---|
| 465 |
if(d < 0) { d += pi2; } |
|---|
| 466 |
if(d > Math.PI) { d -= pi2; } |
|---|
| 467 |
return d; |
|---|
| 468 |
|
|---|
| 469 |
/* --- sticky -------------------------------------------------------------------------- * |
|---|
| 470 |
* :dが[-π,0)のときに無駄な計算をしている気がする - alumican |
|---|
| 471 |
* :これでも大丈夫ぽいけど,剰余計算が重そう - alumican |
|---|
| 472 |
* return( ((target % pi2) - (current % pi2) + 3 * Math.PI) % (2 * Math.PI) - Math.PI; |
|---|
| 473 |
* ------------------------------------------------------------------------------------- */ |
|---|
| 474 |
} |
|---|
| 475 |
|
|---|
| 476 |
} |
|---|
| 477 |
} |
|---|