com.j_phone.util
クラス Vector2D

java.lang.Object
  |
  +--com.j_phone.util.Vector2D

public class Vector2D
extends java.lang.Object

Vector2Dクラスは、2次元ベクトル演算機能を提供します。Vector2Dのインスタンスは、ベクトルの各要素をFixedPointのインスタンスで保持します。下記の機能を提供します。


コンストラクタの概要
Vector2D()
          Vector2Dコンストラクタ。
Vector2D(FixedPoint x, FixedPoint y)
          Vector2Dコンストラクタ
Vector2D(int x, int y)
          Vector2Dコンストラクタ
 
メソッドの概要
 void add(int x, int y)
          加算します。
 void add(Vector2D vector)
          加算します。
 Vector2D clone()
          コピーします。
 FixedPoint getX()
          X軸方向を取得します。
 FixedPoint getY()
          Y軸方向を取得します。
static FixedPoint innerProduct(Vector2D v1, Vector2D v2)
          内積を計算します。
 void normalize()
          正規化します。
static FixedPoint outerProduct(Vector2D v1, Vector2D v2)
          外積を計算します。
 void setValue(FixedPoint x, FixedPoint y)
          新しい値を設定します。
 void setValue(int x, int y)
          新しい値を設定します。
 void subtract(int x, int y)
          減算します。
 void subtract(Vector2D vector)
          減算します。
 
クラス java.lang.Object から継承したメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Vector2D

public Vector2D(FixedPoint x,
                FixedPoint y)
Vector2Dコンストラクタ
パラメータ:
x - X軸方向
y - Y軸方向

Vector2D

public Vector2D(int x,
                int y)
Vector2Dコンストラクタ
パラメータ:
x - X軸方向
y - Y軸方向

Vector2D

public Vector2D()
Vector2Dコンストラクタ。 (0.0, 0.0)になります。
メソッドの詳細

add

public void add(Vector2D vector)
加算します。
パラメータ:
vector - 加算するベクトル
例外:
NullPointerException - vectorが null の場合に発生する

add

public void add(int x,
                int y)
加算します。
パラメータ:
x - 加算するベクトルのX軸方向
y - 加算するベクトルのy軸方向

subtract

public void subtract(Vector2D vector)
減算します。
パラメータ:
vector - 減算するベクトル
例外:
NullPointerException - vectorが null の場合に発生する

subtract

public void subtract(int x,
                     int y)
減算します。
パラメータ:
x - 減算するベクトルのX軸方向
y - 減算するベクトルのy軸方向

normalize

public void normalize()
正規化します。

innerProduct

public static FixedPoint innerProduct(Vector2D v1,
                                      Vector2D v2)
内積を計算します。
パラメータ:
v1 - ベクトル1
v2 - ベクトル2
戻り値:
計算結果
例外:
NullPointerException - v1 または v2 が null の場合に発生する

outerProduct

public static FixedPoint outerProduct(Vector2D v1,
                                      Vector2D v2)
外積を計算します。
パラメータ:
v1 - ベクトル1
v2 - ベクトル2
戻り値:
計算結果
例外:
NullPointerException - v1 または v2 が null の場合に発生する

setValue

public void setValue(int x,
                     int y)
新しい値を設定します。
パラメータ:
x - ベクトルのX軸方向
y - ベクトルのy軸方向

setValue

public void setValue(FixedPoint x,
                     FixedPoint y)
新しい値を設定します。
パラメータ:
x - ベクトルのX軸方向
y - ベクトルのy軸方向
例外:
NullPointerException - x または y が null の場合に発生する

getX

public FixedPoint getX()
X軸方向を取得します。
戻り値:
X軸方向の値

getY

public FixedPoint getY()
Y軸方向を取得します。
戻り値:
Y軸方向の値

clone

public Vector2D clone()
コピーします。
戻り値:
中身が同じVector2D