KisaragiLibrary
 
読み取り中…
検索中…
一致する文字列を見つけられません
Kisaragi_Lib::Vector2D< T > 構造体テンプレート

ベクトルを表すプリミティブ型 [詳解]

#include <Primitive.hpp>

Kisaragi_Lib::Vector2D< T > の継承関係図
Kisaragi_Lib::Point2D< T >

公開メンバ関数

 Vector2D ()
 
 Vector2D (T _x, T _y)
 
Vector2D operator= (Point2D< T > _p)
 
 Vector2D (const Point2D< T > &_p)
 
bool isVertical (const Vector2D _vec) const
 
bool isParallel (const Vector2D _vec) const
 
bool isSharpAngle (const Vector2D _vec) const
 
double Degree ()
 自身の角度を求める.
 
double ToRadian ()
 方向ベクトルからラジアン値を求める.
 
- 基底クラス Kisaragi_Lib::Point2D< T > に属する継承公開メンバ関数
 Point2D ()
 
 Point2D (T _x, T _y)
 
Point2D operator+ (const Point2D _num) const
 
Point2D operator- (const Point2D _num) const
 
Point2D operator* (const Point2D _num) const
 
Point2D operator/ (const Point2D _num) const
 
const Point2D operator+= (const Point2D _num)
 
const Point2D operator-= (const Point2D _num)
 
const Point2D operator*= (const Point2D _num)
 
const Point2D operator/= (const Point2D _num)
 
Point2D operator* (T _num) const
 
Point2D operator/ (T _num) const
 
const Point2D operator*= (T _num)
 
const Point2D operator/= (T _num)
 
Point2D operator- () const
 
Dot (const Point2D _num) const
 
Cross (const Point2D _num) const
 
Length () const
 
Point2D< T > Normalize ()
 ベクトルを正規化する.
 
Point2D GetNormalize () const
 

静的公開メンバ関数

static Vector2D< T > GetNormalVector (Vector2D< T > _vec, bool _clockwise=true)
 ベクトルから法線ベクトルを求める
 
template<typename Type>
static Vector2D< Type > PointToVector (const Point2D< Type > _startPoint, const Point2D< Type > _endPoint)
 2点から方向ベクトル(非正規)を得る
 
static double ToDegree (Vector2D< T > _vec)
 正規化された方向ベクトルから角度を求める.
 
template<typename T>
static double ToRadian (Vector2D< T > _vec)
 方向ベクトルからラジアン値を求める.
 
template<typename type>
static Vector2D< type > RadianToVector (const type _radian)
 ラジアンからベクトルを取得する. 0度がどこかは知らない.
 

その他の継承メンバ

- 基底クラス Kisaragi_Lib::Point2D< T > に属する継承公開変数類
x
 
y
 

詳解

template<typename T>
struct Kisaragi_Lib::Vector2D< T >

ベクトルを表すプリミティブ型

テンプレート引数
Tベクトルの型
から
ver1.0.0 コメント追加

構築子と解体子

◆ Vector2D() [1/3]

◆ Vector2D() [2/3]

template<typename T>
Kisaragi_Lib::Vector2D< T >::Vector2D ( T _x,
T _y )
inline
213: Point2D<T>(_x, _y) {}
ベクトルを表すプリミティブ型
Definition Primitive.hpp:203

◆ Vector2D() [3/3]

template<typename T>
Kisaragi_Lib::Vector2D< T >::Vector2D ( const Point2D< T > & _p)
inlineexplicit
224: Point2D<T>(_p.x, _p.y) {}
T y
Definition Primitive.hpp:30
T x
Definition Primitive.hpp:30

関数詳解

◆ operator=()

template<typename T>
Vector2D Kisaragi_Lib::Vector2D< T >::operator= ( Point2D< T > _p)
inline
216 {
217 x = _p.x;
218 y = _p.y;
219
220 return *this;
221 }

◆ isVertical()

template<typename T>
bool Kisaragi_Lib::Vector2D< T >::isVertical ( const Vector2D< T > _vec) const
inline
228 {
229 T dot = Dot(_vec);
230 return IsRange(dot, -EPSILON, EPSILON);
231 }
static bool IsRange(T _val, T _rangeMin, T _rangeMax)
valが範囲内か調べる
Definition utility.hpp:59
T Dot(const Point2D _num) const
Definition Primitive.hpp:126

◆ isParallel()

template<typename T>
bool Kisaragi_Lib::Vector2D< T >::isParallel ( const Vector2D< T > _vec) const
inline
235 {
236 T cross = Cross(_vec);
237 return IsRange(cross, -EPSILON, EPSILON);
238 }
T Cross(const Point2D _num) const
Definition Primitive.hpp:132

◆ isSharpAngle()

template<typename T>
bool Kisaragi_Lib::Vector2D< T >::isSharpAngle ( const Vector2D< T > _vec) const
inline
242 {
243 return (Dot(_vec) >= 0.0f);
244 }

◆ GetNormalVector()

template<typename T>
static Vector2D< T > Kisaragi_Lib::Vector2D< T >::GetNormalVector ( Vector2D< T > _vec,
bool _clockwise = true )
inlinestatic

ベクトルから法線ベクトルを求める

テンプレート引数
TVector2Dの型
引数
_clockwise時計回りの法線ベクトルにするか
戻り値
法線ベクトル
253 {
255
256 //時計回りの法線ベクトルが欲しいなら
257 if (_clockwise)
258 {
259 vec = Vector2D<T>(-_vec.y, _vec.x);
260 }
261 else
262 {
263 vec = Vector2D<T>(_vec.y, -_vec.x);
264 }
265
266 vec.Normalize();
267
268 return vec;
269 }
Point2D< T > Normalize()
ベクトルを正規化する.
Definition Primitive.hpp:150
Vector2D()
Definition Primitive.hpp:212

参照元 Kisaragi_Lib::GetSeparationAxis().

◆ PointToVector()

template<typename T>
template<typename Type>
static Vector2D< Type > Kisaragi_Lib::Vector2D< T >::PointToVector ( const Point2D< Type > _startPoint,
const Point2D< Type > _endPoint )
inlinestatic

2点から方向ベクトル(非正規)を得る

テンプレート引数
Type座標の型
引数
_startPoint始点
_endPoint終点
戻り値
始点か終点 への方向ベクトル(非正規)
281 {
283 }

参照元 Kisaragi_Lib::Polygon2D< T >::GetEdge().

◆ ToDegree()

template<typename T>
static double Kisaragi_Lib::Vector2D< T >::ToDegree ( Vector2D< T > _vec)
inlinestatic

正規化された方向ベクトルから角度を求める.

テンプレート引数
Tベクトルの型
引数
_vec正規化された方向ベクトル
戻り値
角度
292 {
293 //正規化
294 _vec.Normalize();
295
297 }
static double RadianToDegree(const double &_radian)
ラジアン値を角度に変換する.
Definition KisaragiMath.hpp:47

◆ Degree()

template<typename T>
double Kisaragi_Lib::Vector2D< T >::Degree ( )
inline

自身の角度を求める.

テンプレート引数
Tベクトルの型
引数
_vec正規化された方向ベクトル
戻り値
角度
306 {
307 //正規化
308 Vector2D<T> _vec = *this;
309 _vec = GetNormalize();
310
312 }
Point2D GetNormalize() const
Definition Primitive.hpp:176

◆ ToRadian() [1/2]

template<typename T>
template<typename T>
static double Kisaragi_Lib::Vector2D< T >::ToRadian ( Vector2D< T > _vec)
inlinestatic

方向ベクトルからラジアン値を求める.

テンプレート引数
Tベクトルの型
引数
_vec正規化された方向ベクトル
戻り値
ラジアン値
322 {
323 //正規化
324 _vec.Normalize();
325
326 return atan2(_vec.y, _vec.x);
327 }

◆ ToRadian() [2/2]

template<typename T>
double Kisaragi_Lib::Vector2D< T >::ToRadian ( )
inline

方向ベクトルからラジアン値を求める.

引数
_vec正規化された方向ベクトル
戻り値
ラジアン値
335 {
336 Vector2D<T> _vec = *this;
337 _vec.Normalize();
338
339 return atan2(_vec.y, _vec.x);
340 }

◆ RadianToVector()

template<typename T>
template<typename type>
static Vector2D< type > Kisaragi_Lib::Vector2D< T >::RadianToVector ( const type _radian)
inlinestatic

ラジアンからベクトルを取得する. 0度がどこかは知らない.

テンプレート引数
typeベクトルの型
引数
_radianラジアン値
戻り値
取得したベクトル
351 {
353 tmp.x = cos(_radian);
354 tmp.y = sin(_radian);
355
356 return Vector2D<type>{ tmp.Normalize()};
357 }

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