2次元の位置ベクトルを表す構造体.
[詳解]
#include <math_vector2.h>
2次元の位置ベクトルを表す構造体.
参考
本当はテンプレート構造体にするべき. しかし,実用的に使用するのは2次元,3次元程度であるため, このようにそれぞれ実装する.
math_vector2.h の 30 行目に定義があります。
◆ Vector2() [1/4]
constexpr designlab::Vector2::Vector2 |
( |
| ) |
|
|
inlineconstexpr |
◆ Vector2() [2/4]
constexpr designlab::Vector2::Vector2 |
( |
float |
x_pos, |
|
|
float |
y_pos |
|
) |
| |
|
inlineconstexpr |
◆ 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 |
自分×引数 の外積の結果を返す.
- 引数
-
- 戻り値
- このベクトルと other の外積.
- 覚え書き
- 2次元なので,外積はスカラー.
math_vector2.h の 96 行目に定義があります。
◆ Dot()
constexpr float designlab::Vector2::Dot |
( |
const Vector2 & |
other | ) |
const |
|
inlineconstexprnoexcept |
◆ GetDistanceFrom()
float designlab::Vector2::GetDistanceFrom |
( |
const Vector2 & |
other | ) |
const |
|
inlinenoexcept |
◆ GetLength()
float designlab::Vector2::GetLength |
( |
| ) |
const |
|
inline |
このベクトルの長さを返す.
- 戻り値
- このベクトルの長さ.
- 覚え書き
- sqrtは重いので,長さの2乗を返す GetSquaredLength を使うことを推奨.
math_vector2.h の 80 行目に定義があります。
◆ GetNormalized()
Vector2 designlab::Vector2::GetNormalized |
( |
| ) |
const |
◆ GetSquaredLength()
constexpr float designlab::Vector2::GetSquaredLength |
( |
| ) |
const |
|
inlineconstexprnoexcept |
このベクトルの長さの2乗を返す.
- 戻り値
- このベクトルの長さの2乗.
- 覚え書き
- sqrt(ルートの計算)が重いのでこちらを使えるなら使うべき.
math_vector2.h の 74 行目に定義があります。
◆ GetZeroVec()
static constexpr Vector2 designlab::Vector2::GetZeroVec |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
◆ IsZero()
constexpr bool designlab::Vector2::IsZero |
( |
| ) |
const |
|
inlineconstexprnoexcept |
このベクトルが0ならば true.
- 戻り値
- このベクトルが0ならば true.
- 覚え書き
- 誤差を考慮している.
math_vector2.h の 119 行目に定義があります。
◆ Normalize()
void designlab::Vector2::Normalize |
( |
| ) |
|
|
inlinenoexcept |
このベクトルを正規化する.
絶対値が0のベクトルの場合,そのまま0ベクトルになる.
- 注意
- この関数は,このベクトルの値を変更する. GetNormalized は値を変更しない. 間違えないようにすること.
math_vector2.h の 129 行目に定義があります。
◆ operator!=()
constexpr bool designlab::Vector2::operator!= |
( |
const Vector2 & |
other | ) |
const |
|
inlineconstexpr |
◆ operator*()
constexpr Vector2 designlab::Vector2::operator* |
( |
float |
s | ) |
const |
|
inlineconstexpr |
◆ operator*=()
Vector2 & designlab::Vector2::operator*= |
( |
float |
s | ) |
|
◆ operator+() [1/2]
constexpr Vector2 designlab::Vector2::operator+ |
( |
| ) |
const |
|
inlineconstexpr |
◆ operator+() [2/2]
constexpr Vector2 designlab::Vector2::operator+ |
( |
const Vector2 & |
other | ) |
const |
|
inlineconstexpr |
◆ operator+=()
◆ operator-() [1/2]
constexpr Vector2 designlab::Vector2::operator- |
( |
| ) |
const |
|
inlineconstexpr |
◆ operator-() [2/2]
constexpr Vector2 designlab::Vector2::operator- |
( |
const Vector2 & |
other | ) |
const |
|
inlineconstexpr |
◆ operator-=()
◆ operator/()
constexpr Vector2 designlab::Vector2::operator/ |
( |
float |
s | ) |
const |
|
inlineconstexpr |
◆ operator/=()
Vector2 & designlab::Vector2::operator/= |
( |
float |
s | ) |
|
◆ operator=()
constexpr Vector2 & designlab::Vector2::operator= |
( |
const Vector2 & |
other | ) |
|
|
constexprdefault |
◆ operator==()
constexpr bool designlab::Vector2::operator== |
( |
const Vector2 & |
other | ) |
const |
|
inlineconstexpr |
◆ ToCsvString()
std::string designlab::Vector2::ToCsvString |
( |
| ) |
const |
このベクトルをCSV形式の文字列にして返す.
x, y, z の形式,小数点以下3桁まで.
- 戻り値
- このベクトルをCSV形式の文字列にしたもの.
math_vector2.cpp の 63 行目に定義があります。
◆ ToString()
std::string designlab::Vector2::ToString |
( |
| ) |
const |
このベクトルを文字列にして返す.
(x, y) の形式,小数点以下3桁まで.
- 戻り値
- このベクトルを文字列にしたもの.
math_vector2.cpp の 54 行目に定義があります。
float designlab::Vector2::x |
float designlab::Vector2::y |
この構造体詳解は次のファイルから抽出されました: