GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
公開メンバ関数 | 静的公開メンバ関数 | 公開変数類 | 全メンバ一覧
designlab::Vector2 構造体final

2次元の位置ベクトルを表す構造体. [詳解]

#include <math_vector2.h>

公開メンバ関数

constexpr Vector2 ()
 
constexpr Vector2 (float x_pos, float y_pos)
 
constexpr Vector2 (const Vector2 &other)=default
 
constexpr Vector2 (Vector2 &&other) noexcept=default
 
constexpr Vector2operator= (const Vector2 &other)=default
 
constexpr Vector2 operator+ () const
 
constexpr Vector2 operator- () const
 
constexpr Vector2 operator+ (const Vector2 &other) const
 
constexpr Vector2 operator- (const Vector2 &other) const
 
constexpr Vector2 operator* (float s) const
 
constexpr Vector2 operator/ (float s) const
 
Vector2operator+= (const Vector2 &other)
 
Vector2operator-= (const Vector2 &other)
 
Vector2operator*= (float s)
 
Vector2operator/= (float s)
 
constexpr bool operator== (const Vector2 &other) const
 
constexpr bool operator!= (const Vector2 &other) const
 
constexpr float GetSquaredLength () const noexcept
 このベクトルの長さの2乗を返す.
 
float GetLength () const
 このベクトルの長さを返す.
 
constexpr float Dot (const Vector2 &other) const noexcept
 自分・引数 の内積の結果を返す.
 
constexpr float Cross (const Vector2 &other) const noexcept
 自分×引数 の外積の結果を返す.
 
float GetDistanceFrom (const Vector2 &other) const noexcept
 このベクトルと other の距離を返す.
 
Vector2 GetNormalized () const
 このベクトルを正規化したベクトルを返す.
 
constexpr bool IsZero () const noexcept
 このベクトルが0ならば true.
 
void Normalize () noexcept
 このベクトルを正規化する.
絶対値が0のベクトルの場合,そのまま0ベクトルになる.
 
std::string ToString () const
 このベクトルを文字列にして返す.
(x, y) の形式,小数点以下3桁まで.
 
std::string ToCsvString () const
 このベクトルをCSV形式の文字列にして返す.
x, y, z の形式,小数点以下3桁まで.
 

静的公開メンバ関数

static constexpr Vector2 GetZeroVec () noexcept
 零ベクトルを返す. 静的な関数なので Vector2::GetZeroVec() と呼ぶことができる.
 

公開変数類

float x
 
float y
 

詳解

2次元の位置ベクトルを表す構造体.

参考

本当はテンプレート構造体にするべき. しかし,実用的に使用するのは2次元,3次元程度であるため, このようにそれぞれ実装する.

math_vector2.h30 行目に定義があります。

構築子と解体子

◆ Vector2() [1/4]

constexpr designlab::Vector2::Vector2 ( )
inlineconstexpr

math_vector2.h32 行目に定義があります。

被呼び出し関係図:

◆ Vector2() [2/4]

constexpr designlab::Vector2::Vector2 ( float  x_pos,
float  y_pos 
)
inlineconstexpr

math_vector2.h33 行目に定義があります。

◆ Vector2() [3/4]

constexpr designlab::Vector2::Vector2 ( const Vector2 other)
constexprdefault

◆ Vector2() [4/4]

constexpr designlab::Vector2::Vector2 ( Vector2 &&  other)
constexprdefaultnoexcept

関数詳解

◆ Cross()

constexpr float designlab::Vector2::Cross ( const Vector2 other) const
inlineconstexprnoexcept

自分×引数 の外積の結果を返す.

引数
[in]other他のベクトル.
戻り値
このベクトルと other の外積.
覚え書き
2次元なので,外積はスカラー.

math_vector2.h96 行目に定義があります。

被呼び出し関係図:

◆ Dot()

constexpr float designlab::Vector2::Dot ( const Vector2 other) const
inlineconstexprnoexcept

自分・引数 の内積の結果を返す.

引数
[in]other他のベクトル.
戻り値
このベクトルと other の内積.

math_vector2.h86 行目に定義があります。

被呼び出し関係図:

◆ GetDistanceFrom()

float designlab::Vector2::GetDistanceFrom ( const Vector2 other) const
inlinenoexcept

このベクトルと other の距離を返す.

引数
[in]other他のベクトル.
戻り値
このベクトルと other の距離.

math_vector2.h105 行目に定義があります。

◆ GetLength()

float designlab::Vector2::GetLength ( ) const
inline

このベクトルの長さを返す.

戻り値
このベクトルの長さ.
覚え書き
sqrtは重いので,長さの2乗を返す GetSquaredLength を使うことを推奨.

math_vector2.h80 行目に定義があります。

呼び出し関係図:
被呼び出し関係図:

◆ GetNormalized()

Vector2 designlab::Vector2::GetNormalized ( ) const

このベクトルを正規化したベクトルを返す.

戻り値
正規化されたベクトル.

math_vector2.cpp42 行目に定義があります。

呼び出し関係図:
被呼び出し関係図:

◆ GetSquaredLength()

constexpr float designlab::Vector2::GetSquaredLength ( ) const
inlineconstexprnoexcept

このベクトルの長さの2乗を返す.

戻り値
このベクトルの長さの2乗.
覚え書き
sqrt(ルートの計算)が重いのでこちらを使えるなら使うべき.

math_vector2.h74 行目に定義があります。

呼び出し関係図:
被呼び出し関係図:

◆ GetZeroVec()

static constexpr Vector2 designlab::Vector2::GetZeroVec ( )
inlinestaticconstexprnoexcept

零ベクトルを返す. 静的な関数なので Vector2::GetZeroVec() と呼ぶことができる.

戻り値
零ベクトル.

math_vector2.h136 行目に定義があります。

呼び出し関係図:

◆ IsZero()

constexpr bool designlab::Vector2::IsZero ( ) const
inlineconstexprnoexcept

このベクトルが0ならば true.

戻り値
このベクトルが0ならば true.
覚え書き
誤差を考慮している.

math_vector2.h119 行目に定義があります。

呼び出し関係図:

◆ Normalize()

void designlab::Vector2::Normalize ( )
inlinenoexcept

このベクトルを正規化する.
絶対値が0のベクトルの場合,そのまま0ベクトルになる.

注意
この関数は,このベクトルの値を変更する. GetNormalized は値を変更しない. 間違えないようにすること.

math_vector2.h129 行目に定義があります。

呼び出し関係図:

◆ operator!=()

constexpr bool designlab::Vector2::operator!= ( const Vector2 other) const
inlineconstexpr

math_vector2.h64 行目に定義があります。

◆ operator*()

constexpr Vector2 designlab::Vector2::operator* ( float  s) const
inlineconstexpr

math_vector2.h51 行目に定義があります。

◆ operator*=()

Vector2 & designlab::Vector2::operator*= ( float  s)

math_vector2.cpp28 行目に定義があります。

◆ operator+() [1/2]

constexpr Vector2 designlab::Vector2::operator+ ( ) const
inlineconstexpr

math_vector2.h38 行目に定義があります。

◆ operator+() [2/2]

constexpr Vector2 designlab::Vector2::operator+ ( const Vector2 other) const
inlineconstexpr

math_vector2.h41 行目に定義があります。

◆ operator+=()

Vector2 & designlab::Vector2::operator+= ( const Vector2 other)

math_vector2.cpp14 行目に定義があります。

◆ operator-() [1/2]

constexpr Vector2 designlab::Vector2::operator- ( ) const
inlineconstexpr

math_vector2.h39 行目に定義があります。

◆ operator-() [2/2]

constexpr Vector2 designlab::Vector2::operator- ( const Vector2 other) const
inlineconstexpr

math_vector2.h46 行目に定義があります。

◆ operator-=()

Vector2 & designlab::Vector2::operator-= ( const Vector2 other)

math_vector2.cpp21 行目に定義があります。

◆ operator/()

constexpr Vector2 designlab::Vector2::operator/ ( float  s) const
inlineconstexpr

math_vector2.h52 行目に定義があります。

◆ operator/=()

Vector2 & designlab::Vector2::operator/= ( float  s)

math_vector2.cpp35 行目に定義があります。

◆ operator=()

constexpr Vector2 & designlab::Vector2::operator= ( const Vector2 other)
constexprdefault

◆ operator==()

constexpr bool designlab::Vector2::operator== ( const Vector2 other) const
inlineconstexpr

math_vector2.h59 行目に定義があります。

呼び出し関係図:

◆ ToCsvString()

std::string designlab::Vector2::ToCsvString ( ) const

このベクトルをCSV形式の文字列にして返す.
x, y, z の形式,小数点以下3桁まで.

戻り値
このベクトルをCSV形式の文字列にしたもの.

math_vector2.cpp63 行目に定義があります。

呼び出し関係図:

◆ ToString()

std::string designlab::Vector2::ToString ( ) const

このベクトルを文字列にして返す.
(x, y) の形式,小数点以下3桁まで.

戻り値
このベクトルを文字列にしたもの.

math_vector2.cpp54 行目に定義があります。

呼び出し関係図:
被呼び出し関係図:

メンバ詳解

◆ x

float designlab::Vector2::x

math_vector2.h149 行目に定義があります。

◆ y

float designlab::Vector2::y

math_vector2.h150 行目に定義があります。


この構造体詳解は次のファイルから抽出されました: