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

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

#include <math_vector3.h>

公開メンバ関数

constexpr Vector3 ()
 < デフォルトコンストラクタ.(0,0,0)で初期化される.
 
constexpr Vector3 (const float x_pos, const float y_pos, const float z_pos)
 
constexpr Vector3 (const Vector3 &other)=default
 コピーコンストラクタ.
 
constexpr Vector3 (Vector3 &&other) noexcept=default
 ムーブコンストラクタ.
 
constexpr Vector3operator= (const Vector3 &other)=default
 代入演算子.
 
 ~Vector3 ()=default
 
constexpr bool operator== (const Vector3 &v) const noexcept
 2つのベクトルが等しいかどうかを返す.誤差を許容する.
 
constexpr bool operator!= (const Vector3 &other) const noexcept
 
bool operator< (const Vector3 &other) const noexcept
 
bool operator> (const Vector3 &other) const noexcept
 
bool operator<= (const Vector3 &other) const noexcept
 
bool operator>= (const Vector3 &other) const noexcept
 
constexpr Vector3 operator+ () const noexcept
 
constexpr Vector3 operator- () const noexcept
 
constexpr Vector3 operator+ (const Vector3 &other) const noexcept
 
constexpr Vector3 operator- (const Vector3 &other) const noexcept
 
constexpr Vector3 operator* (const float num) const noexcept
 
constexpr Vector3 operator/ (const float num) const
 
Vector3operator+= (const Vector3 &other) noexcept
 
Vector3operator-= (const Vector3 &other) noexcept
 
Vector3operator*= (const float num) noexcept
 
Vector3operator/= (const float num)
 
constexpr float GetSquaredLength () const noexcept
 ベクトルの長さの2乗を返す.
 
float GetLength () const noexcept
 ベクトルの長さを返す.
 
constexpr float Dot (const Vector3 &other) const noexcept
 自分・引数 の内積の結果を返す.
 
constexpr Vector3 Cross (const Vector3 &other) const noexcept
 自分×引数 の外積の結果を返す.
 
float GetDistanceFrom (const Vector3 &other) const noexcept
 別のベクトルと,このベクトルの距離を返す.
 
Vector3 GetNormalized () const noexcept
 単位ベクトルを返す. normalizeとは,ベクトルを正規化(単位ベクトルに変換)する操作を表す.
絶対値が0のベクトルの場合,そのまま0ベクトルを返す.
 
constexpr bool IsZero () const noexcept
 x,y,zともに絶対値が0ならば true を返す.
 
void Normalize () noexcept
 このベクトルを正規化する.
絶対値が0のベクトルの場合,そのまま0ベクトルになる.
 
constexpr Vector2 ProjectedXY () const noexcept
 XY平面に射影したベクトルを返す.
 
std::string ToString () const
 このベクトルを文字列にして返す.
(x, y, z) の形式,小数点以下3桁まで.
 
std::string ToCsvString () const
 このベクトルをCSV形式の文字列にして返す.
x, y, z の形式,小数点以下3桁まで.
 

静的公開メンバ関数

static constexpr Vector3 GetFrontVec () noexcept
 正面に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetFrontVec() と呼び出せる.
 
static constexpr Vector3 GetLeftVec () noexcept
 左に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetLeftVec() と呼び出せる.
 
static constexpr Vector3 GetUpVec () noexcept
 上に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetUpVec() と呼び出せる.
 
static constexpr Vector3 GetZeroVec () noexcept
 零ベクトルを返す. 静的な関数なので,Vector3::GetZeroVec() と呼び出せる.
 

公開変数類

float x
 ロボットの正面方向に正.
 
float y
 ロボットの左向きに正.
 
float z
 ロボットの上向きに正.
 

詳解

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

座標系はロボットの進行方向にXの正,ロボットの上向きにZの正, 右手座標系にYをとっている.

ヘッダファイル内に実装を書くのは個人的には避けたいのだが, constexpr関数を使う場合,このようにする必要がある. constexpr関数はコンパイル時に値を計算できることを, コンパイラに伝えるためのものである. (C言語のマクロのような動作ができる) 実行速度が大切なプロジェクトであるため,このように処理を記述する.

参考

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

構築子と解体子

◆ Vector3() [1/4]

constexpr designlab::Vector3::Vector3 ( )
inlineconstexpr

< デフォルトコンストラクタ.(0,0,0)で初期化される.

math_vector3.h42 行目に定義があります。

◆ Vector3() [2/4]

constexpr designlab::Vector3::Vector3 ( const float  x_pos,
const float  y_pos,
const float  z_pos 
)
inlineconstexpr

math_vector3.h44 行目に定義があります。

◆ Vector3() [3/4]

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

コピーコンストラクタ.

◆ Vector3() [4/4]

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

ムーブコンストラクタ.

◆ ~Vector3()

designlab::Vector3::~Vector3 ( )
default

関数詳解

◆ Cross()

constexpr Vector3 designlab::Vector3::Cross ( const Vector3 other) const
inlineconstexprnoexcept

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

引数
[in]other外積の掛け算:後ろのベクトル.
戻り値
外積の結果. このベクトル→引数へ回転する右ねじが進む方向のベクトルが出力される.

math_vector3.h160 行目に定義があります。

被呼び出し関係図:

◆ Dot()

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

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

引数
[in]otherもう一方のベクトル.
戻り値
内積の結果.

math_vector3.h151 行目に定義があります。

被呼び出し関係図:

◆ GetDistanceFrom()

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

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

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

math_vector3.h168 行目に定義があります。

◆ GetFrontVec()

static constexpr Vector3 designlab::Vector3::GetFrontVec ( )
inlinestaticconstexprnoexcept

正面に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetFrontVec() と呼び出せる.

3次元の位置ベクトルを表す構造体.
static constexpr Vector3 GetFrontVec() noexcept
正面に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetFrontVec() と呼び出せる.
戻り値
正面方向の単位ベクトル,xの正方向.

math_vector3.h211 行目に定義があります。

被呼び出し関係図:

◆ GetLeftVec()

static constexpr Vector3 designlab::Vector3::GetLeftVec ( )
inlinestaticconstexprnoexcept

左に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetLeftVec() と呼び出せる.

戻り値
左方向の単位ベクトル,yの正方向.

math_vector3.h217 行目に定義があります。

被呼び出し関係図:

◆ GetLength()

float designlab::Vector3::GetLength ( ) const
inlinenoexcept

ベクトルの長さを返す.

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

math_vector3.h143 行目に定義があります。

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

◆ GetNormalized()

Vector3 designlab::Vector3::GetNormalized ( ) const
noexcept

単位ベクトルを返す. normalizeとは,ベクトルを正規化(単位ベクトルに変換)する操作を表す.
絶対値が0のベクトルの場合,そのまま0ベクトルを返す.

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

math_vector3.cpp19 行目に定義があります。

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

◆ GetSquaredLength()

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

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

戻り値
x,y,zの値を2乗にして足し合わせたスカラー値.
覚え書き
sqrt(ルートの計算)が重いのでこちらを使えるなら使うべき.

math_vector3.h134 行目に定義があります。

被呼び出し関係図:

◆ GetUpVec()

static constexpr Vector3 designlab::Vector3::GetUpVec ( )
inlinestaticconstexprnoexcept

上に進む単位ベクトルを返す. 静的な関数なので,Vector3::GetUpVec() と呼び出せる.

戻り値
上方向の単位ベクトル,zの正方向.

math_vector3.h223 行目に定義があります。

被呼び出し関係図:

◆ GetZeroVec()

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

零ベクトルを返す. 静的な関数なので,Vector3::GetZeroVec() と呼び出せる.

戻り値
零ベクトル.

math_vector3.h229 行目に定義があります。

被呼び出し関係図:

◆ IsZero()

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

x,y,zともに絶対値が0ならば true を返す.

戻り値
0ならば true そうでなければ false.
覚え書き
誤差を許容する.

math_vector3.h182 行目に定義があります。

呼び出し関係図:

◆ Normalize()

void designlab::Vector3::Normalize ( )
inlinenoexcept

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

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

math_vector3.h197 行目に定義があります。

呼び出し関係図:

◆ operator!=()

constexpr bool designlab::Vector3::operator!= ( const Vector3 other) const
inlineconstexprnoexcept

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

◆ operator*()

constexpr Vector3 designlab::Vector3::operator* ( const float  num) const
inlineconstexprnoexcept

math_vector3.h115 行目に定義があります。

◆ operator*=()

Vector3 & designlab::Vector3::operator*= ( const float  num)
noexcept

math_vector3.cpp64 行目に定義があります。

◆ operator+() [1/2]

constexpr Vector3 designlab::Vector3::operator+ ( ) const
inlineconstexprnoexcept

math_vector3.h101 行目に定義があります。

◆ operator+() [2/2]

constexpr Vector3 designlab::Vector3::operator+ ( const Vector3 other) const
inlineconstexprnoexcept

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

◆ operator+=()

Vector3 & designlab::Vector3::operator+= ( const Vector3 other)
noexcept

math_vector3.cpp48 行目に定義があります。

◆ operator-() [1/2]

constexpr Vector3 designlab::Vector3::operator- ( ) const
inlineconstexprnoexcept

math_vector3.h103 行目に定義があります。

◆ operator-() [2/2]

constexpr Vector3 designlab::Vector3::operator- ( const Vector3 other) const
inlineconstexprnoexcept

math_vector3.h110 行目に定義があります。

◆ operator-=()

Vector3 & designlab::Vector3::operator-= ( const Vector3 other)
noexcept

math_vector3.cpp56 行目に定義があります。

◆ operator/()

constexpr Vector3 designlab::Vector3::operator/ ( const float  num) const
inlineconstexpr

math_vector3.h120 行目に定義があります。

◆ operator/=()

Vector3 & designlab::Vector3::operator/= ( const float  num)

math_vector3.cpp72 行目に定義があります。

◆ operator<()

bool designlab::Vector3::operator< ( const Vector3 other) const
inlinenoexcept

math_vector3.h79 行目に定義があります。

呼び出し関係図:

◆ operator<=()

bool designlab::Vector3::operator<= ( const Vector3 other) const
inlinenoexcept

math_vector3.h90 行目に定義があります。

◆ operator=()

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

代入演算子.

◆ operator==()

constexpr bool designlab::Vector3::operator== ( const Vector3 v) const
inlineconstexprnoexcept

2つのベクトルが等しいかどうかを返す.誤差を許容する.

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

呼び出し関係図:

◆ operator>()

bool designlab::Vector3::operator> ( const Vector3 other) const
inlinenoexcept

math_vector3.h85 行目に定義があります。

◆ operator>=()

bool designlab::Vector3::operator>= ( const Vector3 other) const
inlinenoexcept

math_vector3.h95 行目に定義があります。

◆ ProjectedXY()

constexpr Vector2 designlab::Vector3::ProjectedXY ( ) const
inlineconstexprnoexcept

XY平面に射影したベクトルを返す.

戻り値
XY平面に射影したベクトル.

math_vector3.h202 行目に定義があります。

被呼び出し関係図:

◆ ToCsvString()

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

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

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

math_vector3.cpp41 行目に定義があります。

◆ ToString()

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

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

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

math_vector3.cpp33 行目に定義があります。

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

メンバ詳解

◆ x

float designlab::Vector3::x

ロボットの正面方向に正.

math_vector3.h243 行目に定義があります。

◆ y

float designlab::Vector3::y

ロボットの左向きに正.

math_vector3.h244 行目に定義があります。

◆ z

float designlab::Vector3::z

ロボットの上向きに正.

math_vector3.h245 行目に定義があります。


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