OROCHI
 
Loading...
Searching...
No Matches
GxVectord.inl
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10
11GX_CORE_NAMESPACE_BEGIN()
12
13#define GX_VECTOR_ZERO_VECTOR_CHECK_VALUE F32_ABS_MIN // ゼロベクトルをチェックする定数
14
15//===========================================================================
16// GxVector2d
17//===========================================================================
18//---------------------------------------------------------------------------
19// コンストラクタ
22//---------------------------------------------------------------------------
23GX_FORCE_INLINE GxVector2d::GxVector2d(f64 x, f64 y)
24: _x(x)
25, _y(y)
26{
27}
28
29//---------------------------------------------------------------------------
30// コンストラクタ
32//---------------------------------------------------------------------------
33GX_FORCE_INLINE GxVector2d::GxVector2d(const GxDouble2& double2)
34: _x(double2._x)
35, _y(double2._y)
36{
37}
38
39//---------------------------------------------------------------------------
40// コンストラクタ
42//---------------------------------------------------------------------------
43GX_FORCE_INLINE GxVector2d::GxVector2d(const f64* pDoubleArray)
44: _x(pDoubleArray[0])
45, _y(pDoubleArray[1])
46{
47}
48
49//---------------------------------------------------------------------------
50// コンストラクタ
52//---------------------------------------------------------------------------
53GX_FORCE_INLINE GxVector2d::GxVector2d(const GxPoint2& point)
54: _x(static_cast<f64>(point._x))
55, _y(static_cast<f64>(point._y))
56{
57}
58
59//---------------------------------------------------------------------------
60// コピーコンストラクタ
62//---------------------------------------------------------------------------
63GX_FORCE_INLINE GxVector2d::GxVector2d(const GxVector2d& vector)
64: _x(vector._x)
65, _y(vector._y)
66{
67}
68
69//---------------------------------------------------------------------------
70// 代入
73//---------------------------------------------------------------------------
74GX_FORCE_INLINE GxVector2d& GxVector2d::operator = (const GxVector2d& vector)
75{
76 _x = vector._x;
77 _y = vector._y;
78 return *this;
79}
80
81//---------------------------------------------------------------------------
82// スカラ加算代入
85//---------------------------------------------------------------------------
86GX_FORCE_INLINE GxVector2d& GxVector2d::operator += (f64 scalar)
87{
88 addScalar(scalar);
89 return *this;
90}
91
92//---------------------------------------------------------------------------
93// スカラ減算代入
96//---------------------------------------------------------------------------
97GX_FORCE_INLINE GxVector2d& GxVector2d::operator -= (f64 scalar)
98{
99 subScalar(scalar);
100 return *this;
101}
102
103//---------------------------------------------------------------------------
104// スカラ乗算代入
107//---------------------------------------------------------------------------
108GX_FORCE_INLINE GxVector2d& GxVector2d::operator *= (f64 scalar)
109{
110 mulScalar(scalar);
111 return *this;
112}
113
114//---------------------------------------------------------------------------
115// スカラ除算代入
118//---------------------------------------------------------------------------
119GX_FORCE_INLINE GxVector2d& GxVector2d::operator /= (f64 scalar)
120{
121 divScalar(scalar);
122 return *this;
123}
124
125//---------------------------------------------------------------------------
126// ベクトル加算代入
129//---------------------------------------------------------------------------
130GX_FORCE_INLINE GxVector2d& GxVector2d::operator += (const GxVector2d& vector)
131{
132 addVector(vector);
133 return *this;
134}
135
136//---------------------------------------------------------------------------
137// ベクトル減算代入
140//---------------------------------------------------------------------------
141GX_FORCE_INLINE GxVector2d& GxVector2d::operator -= (const GxVector2d& vector)
142{
143 subVector(vector);
144 return *this;
145}
146
147//---------------------------------------------------------------------------
148// ベクトル乗算代入
151//---------------------------------------------------------------------------
152GX_FORCE_INLINE GxVector2d& GxVector2d::operator *= (const GxVector2d& vector)
153{
154 mulVector(vector);
155 return *this;
156}
157
158//---------------------------------------------------------------------------
159// ベクトル除算代入
162//---------------------------------------------------------------------------
163GX_FORCE_INLINE GxVector2d& GxVector2d::operator /= (const GxVector2d& vector)
164{
165 divVector(vector);
166 return *this;
167}
168
169//---------------------------------------------------------------------------
170// スカラ加算
174//---------------------------------------------------------------------------
175GX_FORCE_INLINE const GxVector2d operator + (const GxVector2d& vector, f64 scalar)
176{
177 GxVector2d result;
178 return GxVector2d::getAddScalar(result, vector, scalar);
179}
180
181//---------------------------------------------------------------------------
182// スカラ減算
186//---------------------------------------------------------------------------
187GX_FORCE_INLINE const GxVector2d operator - (const GxVector2d& vector, f64 scalar)
188{
189 GxVector2d result;
190 return GxVector2d::getSubScalar(result, vector, scalar);
191}
192
193//---------------------------------------------------------------------------
194// スカラ乗算
198//---------------------------------------------------------------------------
199GX_FORCE_INLINE const GxVector2d operator * (const GxVector2d& vector, f64 scalar)
200{
201 GxVector2d result;
202 return GxVector2d::getMulScalar(result, vector, scalar);
203}
204
205//---------------------------------------------------------------------------
206// スカラ乗算
210//---------------------------------------------------------------------------
211GX_FORCE_INLINE const GxVector2d operator * (f64 scalar, const GxVector2d& vector)
212{
213 GxVector2d result;
214 return GxVector2d::getMulScalar(result, vector, scalar);
215}
216
217//---------------------------------------------------------------------------
218// スカラ除算
222//---------------------------------------------------------------------------
223GX_FORCE_INLINE const GxVector2d operator / (const GxVector2d& vector, f64 scalar)
224{
225 GxVector2d result;
226 return GxVector2d::getDivScalar(result, vector, scalar);
227}
228
229//---------------------------------------------------------------------------
230// ベクトル加算
234//---------------------------------------------------------------------------
235GX_FORCE_INLINE const GxVector2d operator + (const GxVector2d& vector0, const GxVector2d& vector1)
236{
237 GxVector2d result;
238 return GxVector2d::getAddVector(result, vector0, vector1);
239}
240
241//---------------------------------------------------------------------------
242// ベクトル減算
246//---------------------------------------------------------------------------
247GX_FORCE_INLINE const GxVector2d operator - (const GxVector2d& vector0, const GxVector2d& vector1)
248{
249 GxVector2d result;
250 return GxVector2d::getSubVector(result, vector0, vector1);
251}
252
253//---------------------------------------------------------------------------
254// ベクトル乗算
258//---------------------------------------------------------------------------
259GX_FORCE_INLINE const GxVector2d operator * (const GxVector2d& vector0, const GxVector2d& vector1)
260{
261 GxVector2d result;
262 return GxVector2d::getMulVector(result, vector0, vector1);
263}
264
265//---------------------------------------------------------------------------
266// ベクトル除算
270//---------------------------------------------------------------------------
271GX_FORCE_INLINE const GxVector2d operator / (const GxVector2d& vector0, const GxVector2d& vector1)
272{
273 GxVector2d result;
274 return GxVector2d::getDivVector(result, vector0, vector1);
275}
276
277//---------------------------------------------------------------------------
278// 一致
282//---------------------------------------------------------------------------
283GX_FORCE_INLINE b32 operator == (const GxVector2d& vector0, const GxVector2d& vector1)
284{
285 return (vector0._x == vector1._x) && (vector0._y == vector1._y);
286}
287
288//---------------------------------------------------------------------------
289// 不一致
293//---------------------------------------------------------------------------
294GX_FORCE_INLINE b32 operator != (const GxVector2d& vector0, const GxVector2d& vector1)
295{
296 return (vector0._x != vector1._x) || (vector0._y != vector1._y);
297}
298
299//---------------------------------------------------------------------------
300// const配列
303//---------------------------------------------------------------------------
304GX_FORCE_INLINE const f64& GxVector2d::operator[](u32 i) const
305{
306 return (&_x)[i];
307}
308
309//---------------------------------------------------------------------------
310// 配列
313//---------------------------------------------------------------------------
314GX_FORCE_INLINE f64& GxVector2d::operator[](u32 i)
315{
316 return (&_x)[i];
317}
318
319//---------------------------------------------------------------------------
320// ゼロベクトル判定
322//---------------------------------------------------------------------------
323GX_FORCE_INLINE b32 GxVector2d::isZeroVector(void) const
324{
325 return (getLengthSquare() <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE);
326}
327
328//---------------------------------------------------------------------------
329// 長さを取得
331//---------------------------------------------------------------------------
332GX_FORCE_INLINE f64 GxVector2d::getLength(void) const
333{
335}
336
337//---------------------------------------------------------------------------
338// 長さの2乗を取得
340//---------------------------------------------------------------------------
341GX_FORCE_INLINE f64 GxVector2d::getLengthSquare(void) const
342{
343 return _x * _x + _y * _y;
344}
345
346//---------------------------------------------------------------------------
347// 長さを設定
349//---------------------------------------------------------------------------
350GX_FORCE_INLINE void GxVector2d::setLength(f64 length)
351{
352 auto oldLength = getLength();
353
354#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
355 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < oldLength * oldLength, "ゼロベクトルに長さを設定しようとしました");
356
357 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
358 if (oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
359 {
360 oldLength = 1.0;
361 }
362#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
363 if( oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
364 {
365 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
366 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
367 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルに長さを設定しようとしました");
368
369 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
370 oldLength = 1.0;
371 }
372#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
373
374 const auto scale = length / oldLength;
375
376 _x *= scale;
377 _y *= scale;
378}
379
380//---------------------------------------------------------------------------
381// 長さを設定(長さ0に対応)
382//
384//---------------------------------------------------------------------------
385GX_FORCE_INLINE void GxVector2d::setLengthEx(f64 length)
386{
387 const auto lengthSquare = getLengthSquare();
388
389 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
390 {
391 const auto scale = length / GxMath::getSqrt(lengthSquare);
392
393 _x *= scale;
394 _y *= scale;
395 }
396 else
397 {
398 _x = 0.0;
399 _y = 0.0;
400 }
401}
402
403//---------------------------------------------------------------------------
404// 正規化ベクトルを取得
406//---------------------------------------------------------------------------
407GX_FORCE_INLINE GxVector2d GxVector2d::getNormalize(void) const
408{
409 auto length = getLength();
410
411#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
412 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
413
414 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
415 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
416 {
417 length = 1.0;
418 }
419#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
420 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
421 {
422 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
423 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
424 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
425
426 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
427 length = 1.0;
428 }
429#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
430
431 const auto inverseLength = 1.0 / length;
432
433 return GxVector2d(_x * inverseLength, _y * inverseLength);
434}
435
436//---------------------------------------------------------------------------
437// 正規化ベクトルを取得(長さ0に対応)
439//---------------------------------------------------------------------------
440GX_FORCE_INLINE GxVector2d GxVector2d::getNormalizeEx(void) const
441{
442 const auto lengthSquare = getLengthSquare();
443
444 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
445 {
446 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
447
448 return GxVector2d(_x * inverseLength, _y * inverseLength);
449 }
450 else
451 {
452 return GxVector2d::ZERO;
453 }
454}
455
456//---------------------------------------------------------------------------
457// スカラ加算を取得
462//---------------------------------------------------------------------------
463GX_FORCE_INLINE const GxVector2d& GxVector2d::getAddScalar(GxVector2d& dst, const GxVector2d& vector, f64 scalar)
464{
465 dst._x = vector._x + scalar;
466 dst._y = vector._y + scalar;
467
468 return dst;
469}
470
471//---------------------------------------------------------------------------
472// スカラ減算を取得
477//---------------------------------------------------------------------------
478GX_FORCE_INLINE const GxVector2d& GxVector2d::getSubScalar(GxVector2d& dst, const GxVector2d& vector, f64 scalar)
479{
480 dst._x = vector._x - scalar;
481 dst._y = vector._y - scalar;
482
483 return dst;
484}
485
486//---------------------------------------------------------------------------
487// スカラ乗算を取得
492//---------------------------------------------------------------------------
493GX_FORCE_INLINE const GxVector2d& GxVector2d::getMulScalar(GxVector2d& dst, const GxVector2d& vector, f64 scalar)
494{
495 dst._x = vector._x * scalar;
496 dst._y = vector._y * scalar;
497
498 return dst;
499}
500
501//---------------------------------------------------------------------------
502// スカラ除算を取得
507//---------------------------------------------------------------------------
508GX_FORCE_INLINE const GxVector2d& GxVector2d::getDivScalar(GxVector2d& dst, const GxVector2d& vector, f64 scalar)
509{
510 auto inverseLength = 1.0 / scalar;
511
512 dst._x = vector._x * inverseLength;
513 dst._y = vector._y * inverseLength;
514
515 return dst;
516}
517
518//---------------------------------------------------------------------------
519// ベクトル加算を取得
524//---------------------------------------------------------------------------
525GX_FORCE_INLINE const GxVector2d& GxVector2d::getAddVector(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
526{
527 dst._x = vector0._x + vector1._x;
528 dst._y = vector0._y + vector1._y;
529
530 return dst;
531}
532
533//---------------------------------------------------------------------------
534// ベクトル減算を取得
539//---------------------------------------------------------------------------
540GX_FORCE_INLINE const GxVector2d& GxVector2d::getSubVector(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
541{
542 dst._x = vector0._x - vector1._x;
543 dst._y = vector0._y - vector1._y;
544
545 return dst;
546}
547
548//---------------------------------------------------------------------------
549// ベクトル乗算を取得
554//---------------------------------------------------------------------------
555GX_FORCE_INLINE const GxVector2d& GxVector2d::getMulVector(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
556{
557 dst._x = vector0._x * vector1._x;
558 dst._y = vector0._y * vector1._y;
559
560 return dst;
561}
562
563//---------------------------------------------------------------------------
564// ベクトル除算を取得
569//---------------------------------------------------------------------------
570GX_FORCE_INLINE const GxVector2d& GxVector2d::getDivVector(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
571{
572 dst._x = vector0._x / vector1._x;
573 dst._y = vector0._y / vector1._y;
574
575 return dst;
576}
577
578//---------------------------------------------------------------------------
579// 正規化ベクトルを取得
583//---------------------------------------------------------------------------
584GX_FORCE_INLINE const GxVector2d& GxVector2d::getNormalize(GxVector2d& dst, const GxVector2d& vector)
585{
586 auto length = vector.getLength();
587
588#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
589 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length* length, "ゼロベクトルを正規化しようとしました");
590
591 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
592 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
593 {
594 length = 1.0;
595 }
596#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
597 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
598 {
599 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
600 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
601 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
602
603 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
604 length = 1.0;
605 }
606#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
607
608 const auto inverseLength = 1.0 / length;
609
610 dst._x = vector._x * inverseLength;
611 dst._y = vector._y * inverseLength;
612
613 return dst;
614}
615
616//---------------------------------------------------------------------------
617// 正規化ベクトルを取得(長さ0に対応)
621//---------------------------------------------------------------------------
622GX_FORCE_INLINE const GxVector2d& GxVector2d::getNormalizeEx(GxVector2d& dst, const GxVector2d& vector)
623{
624 const auto lengthSquare = vector.getLengthSquare();
625
626 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
627 {
628 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
629
630 dst._x = vector._x * inverseLength;
631 dst._y = vector._y * inverseLength;
632 }
633 else
634 {
635 dst._x = 0.0;
636 dst._y = 0.0;
637 }
638
639 return dst;
640}
641
642//---------------------------------------------------------------------------
643// 内積を取得
647//---------------------------------------------------------------------------
648GX_FORCE_INLINE f64 GxVector2d::getDot(const GxVector2d& vector0, const GxVector2d& vector1)
649{
650 return vector0._x * vector1._x + vector0._y * vector1._y;
651}
652
653//---------------------------------------------------------------------------
654// 外積を取得
658//---------------------------------------------------------------------------
659GX_FORCE_INLINE f64 GxVector2d::getCross(const GxVector2d& vector0, const GxVector2d& vector1)
660{
661 return vector0._x * vector1._y - vector0._y * vector1._x;
662}
663
664//---------------------------------------------------------------------------
665// 角度差を取得(符号つき radian)
670//---------------------------------------------------------------------------
671GX_FORCE_INLINE f64 GxVector2d::getAngle(const GxVector2d& vector0, const GxVector2d& vector1)
672{
673 if( vector0.isZeroVector() || vector0.isZeroVector() )
674 {
675 return 0.0;
676 }
677
678 const auto cosTheta = GxVector2d::getDot(vector0, vector1);
679 const auto sinTheta = GxVector2d::getCross(vector0, vector1);
680
681 return GxMath::getATan2(sinTheta, cosTheta);
682}
683
684//---------------------------------------------------------------------------
685// 要素毎に最小値を選択
689//---------------------------------------------------------------------------
690GX_FORCE_INLINE GxVector2d GxVector2d::getMinimum(const GxVector2d& vector0, const GxVector2d& vector1)
691{
692 return GxVector2d(vector0._x < vector1._x ? vector0._x : vector1._x,
693 vector0._y < vector1._y ? vector0._y : vector1._y);
694}
695
696//---------------------------------------------------------------------------
697// 要素毎に最小値を選択
702//---------------------------------------------------------------------------
703GX_FORCE_INLINE const GxVector2d& GxVector2d::getMinimum(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
704{
705 dst._x = vector0._x < vector1._x ? vector0._x : vector1._x;
706 dst._y = vector0._y < vector1._y ? vector0._y : vector1._y;
707
708 return dst;
709}
710
711//---------------------------------------------------------------------------
712// 要素毎に最大値を選択
716//---------------------------------------------------------------------------
717GX_FORCE_INLINE GxVector2d GxVector2d::getMaximum(const GxVector2d& vector0, const GxVector2d& vector1)
718{
719 return GxVector2d(vector0._x > vector1._x ? vector0._x : vector1._x,
720 vector0._y > vector1._y ? vector0._y : vector1._y);
721}
722
723//---------------------------------------------------------------------------
724// 要素毎に最大値を選択
729//---------------------------------------------------------------------------
730GX_FORCE_INLINE const GxVector2d& GxVector2d::getMaximum(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1)
731{
732 dst._x = vector0._x > vector1._x ? vector0._x : vector1._x;
733 dst._y = vector0._y > vector1._y ? vector0._y : vector1._y;
734
735 return dst;
736}
737
738//---------------------------------------------------------------------------
739// 線形補間
744//---------------------------------------------------------------------------
745GX_FORCE_INLINE GxVector2d GxVector2d::getLerp(const GxVector2d& vector0, const GxVector2d& vector1, f64 t)
746{
747 return GxVector2d(vector0._x + (vector1._x - vector0._x) * t,
748 vector0._y + (vector1._y - vector0._y) * t);
749}
750
751//---------------------------------------------------------------------------
752// 線形補間
758//---------------------------------------------------------------------------
759GX_FORCE_INLINE const GxVector2d& GxVector2d::getLerp(GxVector2d& dst, const GxVector2d& vector0, const GxVector2d& vector1, f64 t)
760{
761 dst._x = vector0._x + (vector1._x - vector0._x) * t;
762 dst._y = vector0._y + (vector1._y - vector0._y) * t;
763
764 return dst;
765}
766
767//---------------------------------------------------------------------------
768// スカラ加算
771//---------------------------------------------------------------------------
772GX_FORCE_INLINE const GxVector2d& GxVector2d::addScalar(f64 scalar)
773{
774 _x += scalar;
775 _y += scalar;
776
777 return *this;
778}
779
780//---------------------------------------------------------------------------
781// スカラ減算
784//---------------------------------------------------------------------------
785GX_FORCE_INLINE const GxVector2d& GxVector2d::subScalar(f64 scalar)
786{
787 _x -= scalar;
788 _y -= scalar;
789
790 return *this;
791}
792
793//---------------------------------------------------------------------------
794// スカラ乗算
797//---------------------------------------------------------------------------
798GX_FORCE_INLINE const GxVector2d& GxVector2d::mulScalar(f64 scalar)
799{
800 _x *= scalar;
801 _y *= scalar;
802
803 return *this;
804}
805
806//---------------------------------------------------------------------------
807// スカラ除算
810//---------------------------------------------------------------------------
811GX_FORCE_INLINE const GxVector2d& GxVector2d::divScalar(f64 scalar)
812{
813 auto inverseScalar = 1.0 / scalar;
814
815 _x *= inverseScalar;
816 _y *= inverseScalar;
817
818 return *this;
819}
820
821//---------------------------------------------------------------------------
822// ベクトル加算
825//---------------------------------------------------------------------------
826GX_FORCE_INLINE const GxVector2d& GxVector2d::addVector(const GxVector2d& vector)
827{
828 _x += vector._x;
829 _y += vector._y;
830
831 return *this;
832}
833
834//---------------------------------------------------------------------------
835// ベクトル減算
838//---------------------------------------------------------------------------
839GX_FORCE_INLINE const GxVector2d& GxVector2d::subVector(const GxVector2d& vector)
840{
841 _x -= vector._x;
842 _y -= vector._y;
843
844 return *this;
845}
846
847//---------------------------------------------------------------------------
848// ベクトル乗算
851//---------------------------------------------------------------------------
852GX_FORCE_INLINE const GxVector2d& GxVector2d::mulVector(const GxVector2d& vector)
853{
854 _x *= vector._x;
855 _y *= vector._y;
856
857 return *this;
858}
859
860//---------------------------------------------------------------------------
861// ベクトル除算
864//---------------------------------------------------------------------------
865GX_FORCE_INLINE const GxVector2d& GxVector2d::divVector(const GxVector2d& vector)
866{
867 _x /= vector._x;
868 _y /= vector._y;
869
870 return *this;
871}
872
873//---------------------------------------------------------------------------
874// 正規化する
876//---------------------------------------------------------------------------
877GX_FORCE_INLINE const GxVector2d& GxVector2d::normalize(void)
878{
879 auto length = getLength();
880
881#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
882 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
883
884 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
885 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
886 {
887 length = 1.0;
888 }
889#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
890 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
891 {
892 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
893 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
894 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
895
896 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
897 length = 1.0;
898 }
899#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
900
901 const auto inverseLength = 1.0 / length;
902
903 _x *= inverseLength;
904 _y *= inverseLength;
905
906 return *this;
907}
908
909//---------------------------------------------------------------------------
910// 正規化する(長さ0に対応)
912//---------------------------------------------------------------------------
913GX_FORCE_INLINE const GxVector2d& GxVector2d::normalizeEx(void)
914{
915 const auto lengthSquare = getLengthSquare();
916
917 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
918 {
919 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
920
921 _x *= inverseLength;
922 _y *= inverseLength;
923 }
924 else
925 {
926 _x = 0.0;
927 _y = 0.0;
928 }
929
930 return *this;
931}
932
933//===========================================================================
934// GxVector3d
935//===========================================================================
936//---------------------------------------------------------------------------
937// コンストラクタ
941//---------------------------------------------------------------------------
942GX_FORCE_INLINE GxVector3d::GxVector3d(f64 x, f64 y, f64 z)
943: _x(x)
944, _y(y)
945, _z(z)
946{
947}
948
949//---------------------------------------------------------------------------
950// コンストラクタ
952//---------------------------------------------------------------------------
953GX_FORCE_INLINE GxVector3d::GxVector3d(const GxDouble3& double3)
954: _x(double3._x)
955, _y(double3._y)
956, _z(double3._z)
957{
958}
959
960//---------------------------------------------------------------------------
961// コンストラクタ
963//---------------------------------------------------------------------------
964GX_FORCE_INLINE GxVector3d::GxVector3d(const f64* pDoubleArray)
965: _x(pDoubleArray[0])
966, _y(pDoubleArray[1])
967, _z(pDoubleArray[2])
968{
969}
970
971//---------------------------------------------------------------------------
972// コンストラクタ
975//---------------------------------------------------------------------------
976GX_FORCE_INLINE GxVector3d::GxVector3d(const GxPoint2& point, f64 z)
977: _x(static_cast<f64>(point._x))
978, _y(static_cast<f64>(point._y))
979, _z(z)
980{
981}
982
983//---------------------------------------------------------------------------
984// コンストラクタ
987//---------------------------------------------------------------------------
988GX_FORCE_INLINE GxVector3d::GxVector3d(const GxVector2d& vector, f64 z)
989: _x(vector._x)
990, _y(vector._y)
991, _z(z)
992{
993}
994
995//---------------------------------------------------------------------------
996// コンストラクタ
998//---------------------------------------------------------------------------
999GX_FORCE_INLINE GxVector3d::GxVector3d(const GxVector4d& vector)
1000: _x(vector._x)
1001, _y(vector._y)
1002, _z(vector._z)
1003{
1004}
1005
1006//---------------------------------------------------------------------------
1007// コピーコンストラクタ
1009//---------------------------------------------------------------------------
1010GX_FORCE_INLINE GxVector3d::GxVector3d(const GxVector3d& vector)
1011: _x(vector._x)
1012, _y(vector._y)
1013, _z(vector._z)
1014{
1015}
1016
1017//---------------------------------------------------------------------------
1018// 代入
1021//---------------------------------------------------------------------------
1022GX_FORCE_INLINE GxVector3d& GxVector3d::operator = (const GxVector3d& vector)
1023{
1024 _x = vector._x;
1025 _y = vector._y;
1026 _z = vector._z;
1027 return *this;
1028}
1029
1030//---------------------------------------------------------------------------
1031// スカラ加算代入
1034//---------------------------------------------------------------------------
1035GX_FORCE_INLINE GxVector3d& GxVector3d::operator += (f64 scalar)
1036{
1037 addScalar(scalar);
1038 return *this;
1039}
1040
1041//---------------------------------------------------------------------------
1042// スカラ減算代入
1045//---------------------------------------------------------------------------
1046GX_FORCE_INLINE GxVector3d& GxVector3d::operator -= (f64 scalar)
1047{
1048 subScalar(scalar);
1049 return *this;
1050}
1051
1052//---------------------------------------------------------------------------
1053// スカラ乗算代入
1056//---------------------------------------------------------------------------
1057GX_FORCE_INLINE GxVector3d& GxVector3d::operator *= (f64 scalar)
1058{
1059 mulScalar(scalar);
1060 return *this;
1061}
1062
1063//---------------------------------------------------------------------------
1064// スカラ除算代入
1067//---------------------------------------------------------------------------
1068GX_FORCE_INLINE GxVector3d& GxVector3d::operator /= (f64 scalar)
1069{
1070 divScalar(scalar);
1071 return *this;
1072}
1073
1074//---------------------------------------------------------------------------
1075// ベクトル加算代入
1078//---------------------------------------------------------------------------
1079GX_FORCE_INLINE GxVector3d& GxVector3d::operator += (const GxVector3d& vector)
1080{
1081 addVector(vector);
1082 return *this;
1083}
1084
1085//---------------------------------------------------------------------------
1086// ベクトル減算代入
1089//---------------------------------------------------------------------------
1090GX_FORCE_INLINE GxVector3d& GxVector3d::operator -= (const GxVector3d& vector)
1091{
1092 subVector(vector);
1093 return *this;
1094}
1095
1096//---------------------------------------------------------------------------
1097// ベクトル乗算代入
1100//---------------------------------------------------------------------------
1101GX_FORCE_INLINE GxVector3d& GxVector3d::operator *= (const GxVector3d& vector)
1102{
1103 mulVector(vector);
1104 return *this;
1105}
1106
1107//---------------------------------------------------------------------------
1108// ベクトル除算代入
1111//---------------------------------------------------------------------------
1112GX_FORCE_INLINE GxVector3d& GxVector3d::operator /= (const GxVector3d& vector)
1113{
1114 divVector(vector);
1115 return *this;
1116}
1117
1118//---------------------------------------------------------------------------
1119// スカラ加算
1123//---------------------------------------------------------------------------
1124GX_FORCE_INLINE const GxVector3d operator + (const GxVector3d& vector, f64 scalar)
1125{
1126 GxVector3d result;
1127 return GxVector3d::getAddScalar(result, vector, scalar);
1128}
1129
1130//---------------------------------------------------------------------------
1131// スカラ減算
1135//---------------------------------------------------------------------------
1136GX_FORCE_INLINE const GxVector3d operator - (const GxVector3d& vector, f64 scalar)
1137{
1138 GxVector3d result;
1139 return GxVector3d::getSubScalar(result, vector, scalar);
1140}
1141
1142//---------------------------------------------------------------------------
1143// スカラ乗算
1147//---------------------------------------------------------------------------
1148GX_INLINE const GxVector3d operator * (const GxVector3d& vector, f64 scalar)
1149{
1150 GxVector3d result;
1151 return GxVector3d::getMulScalar(result, vector, scalar);
1152}
1153
1154//---------------------------------------------------------------------------
1155// スカラ乗算
1159//---------------------------------------------------------------------------
1160GX_FORCE_INLINE const GxVector3d operator * (f64 scalar, const GxVector3d& vector)
1161{
1162 GxVector3d result;
1163 return GxVector3d::getMulScalar(result, vector, scalar);
1164}
1165
1166//---------------------------------------------------------------------------
1167// スカラ除算
1171//---------------------------------------------------------------------------
1172GX_FORCE_INLINE const GxVector3d operator / (const GxVector3d& vector, f64 scalar)
1173{
1174 GxVector3d result;
1175 return GxVector3d::getDivScalar(result, vector, scalar);
1176}
1177
1178//---------------------------------------------------------------------------
1179// ベクトル加算
1183//---------------------------------------------------------------------------
1184GX_FORCE_INLINE const GxVector3d operator + (const GxVector3d& vector0, const GxVector3d& vector1)
1185{
1186 GxVector3d result;
1187 return GxVector3d::getAddVector(result, vector0, vector1);
1188}
1189
1190//---------------------------------------------------------------------------
1191// ベクトル減算
1195//---------------------------------------------------------------------------
1196GX_FORCE_INLINE const GxVector3d operator - (const GxVector3d& vector0, const GxVector3d& vector1)
1197{
1198 GxVector3d result;
1199 return GxVector3d::getSubVector(result, vector0, vector1);
1200}
1201
1202//---------------------------------------------------------------------------
1203// ベクトル乗算
1207//---------------------------------------------------------------------------
1208GX_FORCE_INLINE const GxVector3d operator * (const GxVector3d& vector0, const GxVector3d& vector1)
1209{
1210 GxVector3d result;
1211 return GxVector3d::getMulVector(result, vector0, vector1);
1212}
1213
1214//---------------------------------------------------------------------------
1215// ベクトル除算
1219//---------------------------------------------------------------------------
1220GX_FORCE_INLINE const GxVector3d operator / (const GxVector3d& vector0, const GxVector3d& vector1)
1221{
1222 GxVector3d result;
1223 return GxVector3d::getDivVector(result, vector0, vector1);
1224}
1225
1226//---------------------------------------------------------------------------
1227// 一致
1231//---------------------------------------------------------------------------
1232GX_FORCE_INLINE b32 operator == (const GxVector3d& vector0, const GxVector3d& vector1)
1233{
1234 return (vector0._x == vector1._x) && (vector0._y == vector1._y) && (vector0._z == vector1._z);
1235}
1236
1237//---------------------------------------------------------------------------
1238// 不一致
1242//---------------------------------------------------------------------------
1243GX_FORCE_INLINE b32 operator != (const GxVector3d& vector0, const GxVector3d& vector1)
1244{
1245 return (vector0._x != vector1._x) || (vector0._y != vector1._y) || (vector0._z != vector1._z);
1246}
1247
1248//---------------------------------------------------------------------------
1249// const配列
1252//---------------------------------------------------------------------------
1253GX_FORCE_INLINE const f64& GxVector3d::operator[](u32 i) const
1254{
1255 return (&_x)[i];
1256}
1257
1258//---------------------------------------------------------------------------
1259// 配列
1262//---------------------------------------------------------------------------
1263GX_FORCE_INLINE f64& GxVector3d::operator[](u32 i)
1264{
1265 return (&_x)[i];
1266}
1267
1268//---------------------------------------------------------------------------
1269// XY要素のベクトルを取得
1271//---------------------------------------------------------------------------
1272GX_FORCE_INLINE GxVector3d GxVector3d::getXY(void) const
1273{
1274 return GxVector3d(_x, _y, 0.0);
1275}
1276
1277//---------------------------------------------------------------------------
1278// XY要素のベクトルを取得
1281//---------------------------------------------------------------------------
1282GX_FORCE_INLINE const GxVector3d& GxVector3d::getXY(GxVector3d& dst) const
1283{
1284 dst._x = _x;
1285 dst._y = _y;
1286 dst._z = 0.0;
1287
1288 return dst;
1289}
1290
1291//---------------------------------------------------------------------------
1292// XY要素のベクトルを設定
1293//
1295//---------------------------------------------------------------------------
1296GX_FORCE_INLINE void GxVector3d::setXY(const GxVector3d& vector)
1297{
1298 _x = vector._x;
1299 _y = vector._y;
1300}
1301
1302//---------------------------------------------------------------------------
1303// XZ要素のベクトルを取得
1305//---------------------------------------------------------------------------
1306GX_FORCE_INLINE GxVector3d GxVector3d::getXZ(void) const
1307{
1308 return GxVector3d(_x, 0.0, _z);
1309}
1310
1311//---------------------------------------------------------------------------
1312// XZ要素のベクトルを取得
1315//---------------------------------------------------------------------------
1316GX_FORCE_INLINE const GxVector3d& GxVector3d::getXZ(GxVector3d& dst) const
1317{
1318 dst._x = _x;
1319 dst._y = 0.0;
1320 dst._z = _z;
1321
1322 return dst;
1323}
1324
1325//---------------------------------------------------------------------------
1326// XZ要素のベクトルを設定
1327//
1329//---------------------------------------------------------------------------
1330GX_FORCE_INLINE void GxVector3d::setXZ(const GxVector3d& vector)
1331{
1332 _x = vector._x;
1333 _z = vector._z;
1334}
1335
1336//---------------------------------------------------------------------------
1337// YZ要素のベクトルを取得
1339//---------------------------------------------------------------------------
1340GX_FORCE_INLINE GxVector3d GxVector3d::getYZ(void) const
1341{
1342 return GxVector3d(0.0, _y, _z);
1343}
1344
1345//---------------------------------------------------------------------------
1346// YZ要素のベクトルを取得
1349//---------------------------------------------------------------------------
1350GX_FORCE_INLINE const GxVector3d& GxVector3d::getYZ(GxVector3d& dst) const
1351{
1352 dst._x = 0.0;
1353 dst._y = _y;
1354 dst._z = _z;
1355
1356 return dst;
1357}
1358
1359//---------------------------------------------------------------------------
1360// YZ要素のベクトルを設定
1362//---------------------------------------------------------------------------
1363GX_FORCE_INLINE void GxVector3d::setYZ(const GxVector3d& vector)
1364{
1365 _y = vector._y;
1366 _z = vector._z;
1367}
1368
1369//---------------------------------------------------------------------------
1370// ゼロベクトルか判定
1372//---------------------------------------------------------------------------
1373GX_FORCE_INLINE b32 GxVector3d::isZeroVector(void) const
1374{
1375 return (getLengthSquare() <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE);
1376}
1377
1378//---------------------------------------------------------------------------
1379// 長さを取得
1381//---------------------------------------------------------------------------
1382GX_FORCE_INLINE f64 GxVector3d::getLength(void) const
1383{
1385}
1386
1387//---------------------------------------------------------------------------
1388// 長さの2乗を取得
1390//---------------------------------------------------------------------------
1391GX_FORCE_INLINE f64 GxVector3d::getLengthSquare(void) const
1392{
1393 return _x * _x + _y * _y + _z * _z;
1394}
1395
1396//---------------------------------------------------------------------------
1397// 長さを設定
1399//---------------------------------------------------------------------------
1400GX_FORCE_INLINE void GxVector3d::setLength(f64 length)
1401{
1402 auto oldLength = getLength();
1403
1404#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1405 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < oldLength * oldLength, "ゼロベクトルに長さを設定しようとしました");
1406
1407 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1408 if (oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
1409 {
1410 oldLength = 1.0;
1411 }
1412#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1413 if( oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
1414 {
1415 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
1416 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
1417 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルに長さを設定しようとしました");
1418
1419 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1420 oldLength = 1.0;
1421 }
1422#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1423
1424 const auto scale = length / oldLength;
1425
1426 _x *= scale;
1427 _y *= scale;
1428 _z *= scale;
1429}
1430
1431//---------------------------------------------------------------------------
1432// 長さを設定(長さ0に対応)
1433//
1435//---------------------------------------------------------------------------
1436GX_FORCE_INLINE void GxVector3d::setLengthEx(f64 length)
1437{
1438 const auto lengthSquare = getLengthSquare();
1439
1440 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
1441 {
1442 const auto scale = length / GxMath::getSqrt(lengthSquare);
1443
1444 _x *= scale;
1445 _y *= scale;
1446 _z *= scale;
1447 }
1448 else
1449 {
1450 _x = 0.0;
1451 _y = 0.0;
1452 _z = 0.0;
1453 }
1454}
1455
1456//---------------------------------------------------------------------------
1457// 正規化ベクトルを取得
1459//---------------------------------------------------------------------------
1460GX_FORCE_INLINE GxVector3d GxVector3d::getNormalize(void) const
1461{
1462 auto length = getLength();
1463
1464#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1465 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
1466
1467 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1468 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE ) length = 1.0;
1469#else // GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1470 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
1471 {
1472 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
1473 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
1474 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
1475
1476 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1477 length = 1.0;
1478 }
1479#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1480
1481 const auto inverseLength = 1.0 / length;
1482
1483 return GxVector3d(
1484 _x * inverseLength,
1485 _y * inverseLength,
1486 _z * inverseLength);
1487}
1488
1489//---------------------------------------------------------------------------
1490// 正規化ベクトルを取得(長さ0に対応)
1492//---------------------------------------------------------------------------
1493GX_FORCE_INLINE GxVector3d GxVector3d::getNormalizeEx(void) const
1494{
1495 const auto lengthSquare = getLengthSquare();
1496
1497 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
1498 {
1499 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
1500
1501 return GxVector3d(
1502 _x * inverseLength,
1503 _y * inverseLength,
1504 _z * inverseLength);
1505 }
1506 else
1507 {
1508 return GxVector3d(
1509 0.0,
1510 0.0,
1511 0.0);
1512 }
1513}
1514
1515//---------------------------------------------------------------------------
1516// スカラ加算を取得
1521//---------------------------------------------------------------------------
1522GX_FORCE_INLINE const GxVector3d& GxVector3d::getAddScalar(GxVector3d& dst, const GxVector3d& vector, f64 scalar)
1523{
1524 dst._x = vector._x + scalar;
1525 dst._y = vector._y + scalar;
1526 dst._z = vector._z + scalar;
1527
1528 return dst;
1529}
1530
1531//---------------------------------------------------------------------------
1532// スカラ減算を取得
1537//---------------------------------------------------------------------------
1538GX_FORCE_INLINE const GxVector3d& GxVector3d::getSubScalar(GxVector3d& dst, const GxVector3d& vector, f64 scalar)
1539{
1540 dst._x = vector._x - scalar;
1541 dst._y = vector._y - scalar;
1542 dst._z = vector._z - scalar;
1543
1544 return dst;
1545}
1546
1547//---------------------------------------------------------------------------
1548// スカラ乗算を取得
1553//---------------------------------------------------------------------------
1554GX_FORCE_INLINE const GxVector3d& GxVector3d::getMulScalar(GxVector3d& dst, const GxVector3d& vector, f64 scalar)
1555{
1556 dst._x = vector._x * scalar;
1557 dst._y = vector._y * scalar;
1558 dst._z = vector._z * scalar;
1559
1560 return dst;
1561}
1562
1563//---------------------------------------------------------------------------
1564// スカラ除算を取得
1569//---------------------------------------------------------------------------
1570GX_FORCE_INLINE const GxVector3d& GxVector3d::getDivScalar(GxVector3d& dst, const GxVector3d& vector, f64 scalar)
1571{
1572 auto inverseScalar = 1.0 / scalar;
1573
1574 dst._x = vector._x * inverseScalar;
1575 dst._y = vector._y * inverseScalar;
1576 dst._z = vector._z * inverseScalar;
1577
1578 return dst;
1579}
1580
1581//---------------------------------------------------------------------------
1582// ベクトル加算を取得
1587//---------------------------------------------------------------------------
1588GX_FORCE_INLINE const GxVector3d& GxVector3d::getAddVector(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1589{
1590 dst._x = vector0._x + vector1._x;
1591 dst._y = vector0._y + vector1._y;
1592 dst._z = vector0._z + vector1._z;
1593
1594 return dst;
1595}
1596
1597//---------------------------------------------------------------------------
1598// ベクトル減算を取得
1603//---------------------------------------------------------------------------
1604GX_FORCE_INLINE const GxVector3d& GxVector3d::getSubVector(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1605{
1606 dst._x = vector0._x - vector1._x;
1607 dst._y = vector0._y - vector1._y;
1608 dst._z = vector0._z - vector1._z;
1609
1610 return dst;
1611}
1612
1613//---------------------------------------------------------------------------
1614// ベクトル乗算を取得
1619//---------------------------------------------------------------------------
1620GX_FORCE_INLINE const GxVector3d& GxVector3d::getMulVector(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1621{
1622 dst._x = vector0._x * vector1._x;
1623 dst._y = vector0._y * vector1._y;
1624 dst._z = vector0._z * vector1._z;
1625
1626 return dst;
1627}
1628
1629//---------------------------------------------------------------------------
1630// ベクトル除算を取得
1635//---------------------------------------------------------------------------
1636GX_FORCE_INLINE const GxVector3d& GxVector3d::getDivVector(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1637{
1638 dst._x = vector0._x / vector1._x;
1639 dst._y = vector0._y / vector1._y;
1640 dst._z = vector0._z / vector1._z;
1641
1642 return dst;
1643}
1644
1645//---------------------------------------------------------------------------
1646// 正規化ベクトルを取得
1650//---------------------------------------------------------------------------
1651GX_FORCE_INLINE const GxVector3d& GxVector3d::getNormalize(GxVector3d& dst, const GxVector3d& vector)
1652{
1653 auto length = vector.getLength();
1654
1655#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1656 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
1657
1658 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1659 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
1660 {
1661 length = 1.0;
1662 }
1663#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1664 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
1665 {
1666 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
1667 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
1668 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
1669
1670 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
1671 length = 1.0;
1672 }
1673#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
1674
1675 const auto inverseLength = 1.0 / length;
1676
1677 dst._x = vector._x * inverseLength;
1678 dst._y = vector._y * inverseLength;
1679 dst._z = vector._z * inverseLength;
1680
1681 return dst;
1682}
1683
1684//---------------------------------------------------------------------------
1685// 正規化ベクトルを取得(長さ0に対応)
1689//---------------------------------------------------------------------------
1690GX_FORCE_INLINE const GxVector3d& GxVector3d::getNormalizeEx(GxVector3d& dst, const GxVector3d& vector)
1691{
1692 const auto lengthSquare = vector.getLengthSquare();
1693
1694 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
1695 {
1696 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
1697
1698 dst._x = vector._x * inverseLength;
1699 dst._y = vector._y * inverseLength;
1700 dst._z = vector._z * inverseLength;
1701 }
1702 else
1703 {
1704 dst._x = 0.0;
1705 dst._y = 0.0;
1706 dst._z = 0.0;
1707 }
1708
1709 return dst;
1710}
1711
1712//---------------------------------------------------------------------------
1713// 内積を取得
1717//---------------------------------------------------------------------------
1718GX_FORCE_INLINE f64 GxVector3d::getDot(const GxVector3d& vector0, const GxVector3d& vector1)
1719{
1720 return vector0._x * vector1._x + vector0._y * vector1._y + vector0._z * vector1._z;
1721}
1722
1723//---------------------------------------------------------------------------
1724// 外積を取得
1728//---------------------------------------------------------------------------
1729GX_FORCE_INLINE GxVector3d GxVector3d::getCross(const GxVector3d& vector0, const GxVector3d& vector1)
1730{
1731 return GxVector3d( vector0._y * vector1._z - vector0._z * vector1._y,
1732 vector0._z * vector1._x - vector0._x * vector1._z,
1733 vector0._x * vector1._y - vector0._y * vector1._x);
1734}
1735
1736//---------------------------------------------------------------------------
1737// 外積を取得
1742//---------------------------------------------------------------------------
1743GX_FORCE_INLINE const GxVector3d& GxVector3d::getCross(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1744{
1745 dst._x = vector0._y * vector1._z - vector0._z * vector1._y;
1746 dst._y = vector0._z * vector1._x - vector0._x * vector1._z;
1747 dst._z = vector0._x * vector1._y - vector0._y * vector1._x;
1748
1749 return dst;
1750}
1751
1752//---------------------------------------------------------------------------
1753// 直交する単位ベクトルを取得
1756//---------------------------------------------------------------------------
1758{
1759 GxVector3d temporary(vector._z, -vector._x, vector._y);
1760 if(GxVector3d::getDot(vector, temporary) <= -1.0 + DBL_EPSILON)
1761 {
1762 // 真逆
1763 temporary._x = -temporary._x;
1764 }
1765
1766 GxVector3d result;
1767 GxVector3d::getCross(result, vector, temporary);
1768
1769 return result.normalizeEx();
1770}
1771
1772//---------------------------------------------------------------------------
1773// 直交する単位ベクトルを取得
1777//---------------------------------------------------------------------------
1778GX_FORCE_INLINE const GxVector3d& GxVector3d::getCrossVector(GxVector3d& dst, const GxVector3d& vector)
1779{
1780 GxVector3d temporary(vector._z, -vector._x, vector._y);
1781 if(GxVector3d::getDot(vector, temporary) <= -1.0 + DBL_EPSILON)
1782 {
1783 // 真逆
1784 temporary._x = -temporary._x;
1785 }
1786
1787 GxVector3d::getCross(dst, vector, temporary);
1788
1789 return dst.normalizeEx();
1790}
1791
1792//---------------------------------------------------------------------------
1793// 距離を取得
1797//---------------------------------------------------------------------------
1798GX_FORCE_INLINE f64 GxVector3d::getDistance(const GxVector3d& vector0, const GxVector3d& vector1)
1799{
1800 return GxMath::getSqrt(getDistanceSquare(vector0, vector1));
1801}
1802
1803//---------------------------------------------------------------------------
1804// 距離の2乗を取得
1808//---------------------------------------------------------------------------
1809GX_FORCE_INLINE f64 GxVector3d::getDistanceSquare(const GxVector3d& vector0, const GxVector3d& vector1)
1810{
1811 const auto x = vector0._x - vector1._x;
1812 const auto y = vector0._y - vector1._y;
1813 const auto z = vector0._z - vector1._z;
1814
1815 return x * x + y * y + z * z;
1816}
1817
1818//---------------------------------------------------------------------------
1819// 角度差を取得(符号なし radian)
1824//---------------------------------------------------------------------------
1825GX_FORCE_INLINE f64 GxVector3d::getAngle(const GxVector3d& vector0, const GxVector3d& vector1)
1826{
1827 const auto denominator = vector0.getLengthSquare() * vector1.getLengthSquare();
1828
1829 if( denominator <= DBL_EPSILON)
1830 {
1831 return 0.0;
1832 }
1833
1834 const auto value = GxMath::getClamp(getDot(vector0, vector1) / GxMath::getSqrt(denominator), -1.0, 1.0);
1835 return GxMath::getACos(value);
1836}
1837
1838//---------------------------------------------------------------------------
1839// 角度差を取得(符号つき radian)
1845//---------------------------------------------------------------------------
1846GX_FORCE_INLINE f64 GxVector3d::getAngle(const GxVector3d& vector0, const GxVector3d& vector1, const GxVector3d& up)
1847{
1848 const auto denominator = vector0.getLengthSquare() * vector1.getLengthSquare();
1849
1850 if(denominator <= DBL_EPSILON)
1851 {
1852 return 0.0;
1853 }
1854
1855 const auto value = GxMath::getClamp(getDot(vector0, vector1) / GxMath::getSqrt(denominator), -1.0, 1.0);
1856
1857 GxVector3d vector2;
1858 const auto signe = getDot(up, getCross(vector2, vector0, vector1));
1859
1860 return (0.0 <= signe) ? GxMath::getACos(value) : -GxMath::getACos(value);
1861}
1862
1863//---------------------------------------------------------------------------
1864// 要素毎に最小値を選択
1868//---------------------------------------------------------------------------
1869GX_FORCE_INLINE GxVector3d GxVector3d::getMinimum(const GxVector3d& vector0, const GxVector3d& vector1)
1870{
1871 return GxVector3d(vector0._x < vector1._x ? vector0._x : vector1._x,
1872 vector0._y < vector1._y ? vector0._y : vector1._y,
1873 vector0._z < vector1._z ? vector0._z : vector1._z);
1874}
1875
1876//---------------------------------------------------------------------------
1877// 要素毎に最小値を選択
1882//---------------------------------------------------------------------------
1883GX_FORCE_INLINE const GxVector3d& GxVector3d::getMinimum(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1884{
1885 dst._x = vector0._x < vector1._x ? vector0._x : vector1._x;
1886 dst._y = vector0._y < vector1._y ? vector0._y : vector1._y;
1887 dst._z = vector0._z < vector1._z ? vector0._z : vector1._z;
1888
1889 return dst;
1890}
1891
1892//---------------------------------------------------------------------------
1893// 要素毎に最大値を選択
1897//---------------------------------------------------------------------------
1898GX_FORCE_INLINE GxVector3d GxVector3d::getMaximum(const GxVector3d& vector0, const GxVector3d& vector1)
1899{
1900 return GxVector3d(vector0._x > vector1._x ? vector0._x : vector1._x,
1901 vector0._y > vector1._y ? vector0._y : vector1._y,
1902 vector0._z > vector1._z ? vector0._z : vector1._z);
1903}
1904
1905//---------------------------------------------------------------------------
1906// 要素毎に最大値を選択
1911//---------------------------------------------------------------------------
1912GX_FORCE_INLINE const GxVector3d& GxVector3d::getMaximum(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1)
1913{
1914 dst._x = vector0._x > vector1._x ? vector0._x : vector1._x;
1915 dst._y = vector0._y > vector1._y ? vector0._y : vector1._y;
1916 dst._z = vector0._z > vector1._z ? vector0._z : vector1._z;
1917
1918 return dst;
1919}
1920
1921//---------------------------------------------------------------------------
1922// 線形補間
1927//---------------------------------------------------------------------------
1928GX_FORCE_INLINE GxVector3d GxVector3d::getLerp(const GxVector3d& vector0, const GxVector3d& vector1, f64 t)
1929{
1930 return GxVector3d(vector0._x + (vector1._x - vector0._x) * t,
1931 vector0._y + (vector1._y - vector0._y) * t,
1932 vector0._z + (vector1._z - vector0._z) * t);
1933}
1934
1935//---------------------------------------------------------------------------
1936// 線形補間
1942//---------------------------------------------------------------------------
1943GX_FORCE_INLINE const GxVector3d& GxVector3d::getLerp(GxVector3d& dst, const GxVector3d& vector0, const GxVector3d& vector1, f64 t)
1944{
1945 dst._x = vector0._x + (vector1._x - vector0._x) * t;
1946 dst._y = vector0._y + (vector1._y - vector0._y) * t;
1947 dst._z = vector0._z + (vector1._z - vector0._z) * t;
1948
1949 return dst;
1950}
1951
1952//---------------------------------------------------------------------------
1953// 指定した点が線分上のどこに位置するかのパラメータを返す
1961//---------------------------------------------------------------------------
1962GX_FORCE_INLINE f64 GxVector3d::getLineParam(const GxVector3d& checkPosition, const GxVector3d& startPosition, const GxVector3d& endPosition)
1963{
1964 GxVector3d v0(endPosition - startPosition);
1965 GxVector3d v1(checkPosition - startPosition);
1966 auto numerator = GxVector3d::getDot(v0, v1);
1967 auto denominator = GxVector3d::getDot(v0, v0);
1968
1969 // 線分の長さが無いときは 0
1970 if( denominator <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
1971 {
1972 return 0.0;
1973 }
1974
1975 return numerator / denominator;
1976}
1977
1978//---------------------------------------------------------------------------
1979// 指定した点を直線上に下ろした点を取得
1985//---------------------------------------------------------------------------
1986GX_FORCE_INLINE const GxVector3d& GxVector3d::getLinePosition(GxVector3d& dst, const GxVector3d& position, const GxVector3d& linePosition0, const GxVector3d& linePosition1)
1987{
1988 auto t = getLineParam(position, linePosition0, linePosition1);
1989
1990 return GxVector3d::getLerp(dst, linePosition0, linePosition1, t);
1991}
1992
1993//---------------------------------------------------------------------------
1994// 指定した点を直線上に下ろした点を取得
1999//---------------------------------------------------------------------------
2000GX_FORCE_INLINE GxVector3d GxVector3d::getLinePosition(const GxVector3d& position, const GxVector3d& linePosition0, const GxVector3d& linePosition1)
2001{
2002 auto t = getLineParam(position, linePosition0, linePosition1);
2003
2004 return GxVector3d::getLerp(linePosition0, linePosition1, t);
2005}
2006
2007//---------------------------------------------------------------------------
2008// 指定した点を線分上に下ろした点を取得
2014//---------------------------------------------------------------------------
2015GX_FORCE_INLINE const GxVector3d& GxVector3d::getSegmentPosition(GxVector3d& dst, const GxVector3d& position, const GxVector3d& startPosition, const GxVector3d& endPosition)
2016{
2017 auto t = getLineParam(position, startPosition, endPosition);
2018 t = GxMath::getClamp(t, 0.0, 1.0);
2019
2020 return GxVector3d::getLerp(dst, startPosition, endPosition, t);
2021}
2022
2023//---------------------------------------------------------------------------
2024// 指定した点を線分上に下ろした点を取得
2029//---------------------------------------------------------------------------
2030GX_FORCE_INLINE GxVector3d GxVector3d::getSegmentPosition(const GxVector3d& position, const GxVector3d& startPosition, const GxVector3d& endPosition)
2031{
2032 auto t = getLineParam(position, startPosition, endPosition);
2033 t = GxMath::getClamp(t, 0.0, 1.0);
2034
2035 return GxVector3d::getLerp(startPosition, endPosition, t);
2036}
2037
2038//---------------------------------------------------------------------------
2039// ベクトルが同じ方向を向いているか(ラジアン指定/指定値以内なら(==も含む)同じ方向)
2044//---------------------------------------------------------------------------
2045GX_FORCE_INLINE b32 GxVector3d::isSameDirectionLessEqual( const GxVector3d& vector0, const GxVector3d& vector1, f64 limitRadian )
2046{
2047 const auto dot = GxVector3d::getDot(vector0, vector1);
2048 const auto cosRadian = GxMath::getCos(limitRadian);
2049
2050 if( dot > 0.f )
2051 {
2052 if( cosRadian <= 0.f )
2053 {
2054 return true;
2055 }
2056 else if( dot * dot >= vector0.getLengthSquare() * vector1.getLengthSquare() * cosRadian * cosRadian )
2057 {
2058 return true;
2059 }
2060 }
2061 else
2062 {
2063 if( cosRadian <= 0.f &&
2064 dot * dot <= vector0.getLengthSquare() * vector1.getLengthSquare() * cosRadian * cosRadian )
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071}
2072
2073//---------------------------------------------------------------------------
2074// ベクトルが同じ方向を向いているか(ラジアン指定/指定値より小さければ(==は含まない)同じ方向)
2079//---------------------------------------------------------------------------
2080GX_FORCE_INLINE b32 GxVector3d::isSameDirectionLessThan( const GxVector3d& vector0, const GxVector3d& vector1, f64 limitRadian )
2081{
2082 const auto dot = GxVector3d::getDot(vector0, vector1);
2083 const auto cosRadian = GxMath::getCos(limitRadian);
2084
2085 if( dot > 0.f )
2086 {
2087 if( cosRadian < 0.f )
2088 {
2089 return true;
2090 }
2091 else if( dot * dot > vector0.getLengthSquare() * vector1.getLengthSquare() * cosRadian * cosRadian )
2092 {
2093 return true;
2094 }
2095 }
2096 else
2097 {
2098 if( cosRadian < 0.f &&
2099 dot * dot < vector0.getLengthSquare() * vector1.getLengthSquare() * cosRadian * cosRadian )
2100 {
2101 return true;
2102 }
2103 }
2104
2105 return false;
2106}
2107
2108//---------------------------------------------------------------------------
2109// スカラ加算
2112//---------------------------------------------------------------------------
2113GX_FORCE_INLINE const GxVector3d& GxVector3d::addScalar(f64 scalar)
2114{
2115 _x += scalar;
2116 _y += scalar;
2117 _z += scalar;
2118
2119 return *this;
2120}
2121
2122//---------------------------------------------------------------------------
2123// スカラ減算
2126//---------------------------------------------------------------------------
2127GX_FORCE_INLINE const GxVector3d& GxVector3d::subScalar(f64 scalar)
2128{
2129 _x -= scalar;
2130 _y -= scalar;
2131 _z -= scalar;
2132
2133 return *this;
2134}
2135
2136//---------------------------------------------------------------------------
2137// スカラ乗算
2140//---------------------------------------------------------------------------
2141GX_FORCE_INLINE const GxVector3d& GxVector3d::mulScalar(f64 scalar)
2142{
2143 _x *= scalar;
2144 _y *= scalar;
2145 _z *= scalar;
2146
2147 return *this;
2148}
2149
2150//---------------------------------------------------------------------------
2151// スカラ除算
2154//---------------------------------------------------------------------------
2155GX_FORCE_INLINE const GxVector3d& GxVector3d::divScalar(f64 scalar)
2156{
2157 auto inverseScalar = 1.0 / scalar;
2158
2159 _x *= inverseScalar;
2160 _y *= inverseScalar;
2161 _z *= inverseScalar;
2162
2163 return *this;
2164}
2165
2166//---------------------------------------------------------------------------
2167// ベクトル加算
2170//---------------------------------------------------------------------------
2171GX_FORCE_INLINE const GxVector3d& GxVector3d::addVector(const GxVector3d& vector)
2172{
2173 _x += vector._x;
2174 _y += vector._y;
2175 _z += vector._z;
2176
2177 return *this;
2178}
2179
2180//---------------------------------------------------------------------------
2181// ベクトル減算
2184//---------------------------------------------------------------------------
2185GX_FORCE_INLINE const GxVector3d& GxVector3d::subVector(const GxVector3d& vector)
2186{
2187 _x -= vector._x;
2188 _y -= vector._y;
2189 _z -= vector._z;
2190
2191 return *this;
2192}
2193
2194//---------------------------------------------------------------------------
2195// ベクトル乗算
2198//---------------------------------------------------------------------------
2199GX_FORCE_INLINE const GxVector3d& GxVector3d::mulVector(const GxVector3d& vector)
2200{
2201 _x *= vector._x;
2202 _y *= vector._y;
2203 _z *= vector._z;
2204
2205 return *this;
2206}
2207
2208//---------------------------------------------------------------------------
2209// ベクトル除算
2212//---------------------------------------------------------------------------
2213GX_FORCE_INLINE const GxVector3d& GxVector3d::divVector(const GxVector3d& vector)
2214{
2215 _x /= vector._x;
2216 _y /= vector._y;
2217 _z /= vector._z;
2218
2219 return *this;
2220}
2221
2222//---------------------------------------------------------------------------
2223// 正規化する
2225//---------------------------------------------------------------------------
2226GX_FORCE_INLINE const GxVector3d& GxVector3d::normalize(void)
2227{
2228 auto length = getLength();
2229
2230#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2231 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
2232
2233 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2234 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
2235 {
2236 length = 1.0;
2237 }
2238#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2239 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
2240 {
2241 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
2242 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
2243 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
2244
2245 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2246 length = 1.0;
2247 }
2248#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2249
2250 const auto inverseLength = 1.0 / length;
2251
2252 _x *= inverseLength;
2253 _y *= inverseLength;
2254 _z *= inverseLength;
2255
2256 return *this;
2257}
2258
2259//---------------------------------------------------------------------------
2260// 正規化する(長さ0に対応)
2262//---------------------------------------------------------------------------
2263GX_FORCE_INLINE const GxVector3d& GxVector3d::normalizeEx(void)
2264{
2265 const auto lengthSquare = getLengthSquare();
2266
2267 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
2268 {
2269 const f64 inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
2270
2271 _x *= inverseLength;
2272 _y *= inverseLength;
2273 _z *= inverseLength;
2274 }
2275 else
2276 {
2277 _x = 0.0;
2278 _y = 0.0;
2279 _z = 0.0;
2280 }
2281
2282 return *this;
2283}
2284
2285//===========================================================================
2286// GxVector4d
2287//===========================================================================
2288//---------------------------------------------------------------------------
2289// コンストラクタ
2294//---------------------------------------------------------------------------
2295GX_FORCE_INLINE GxVector4d::GxVector4d(f64 x, f64 y, f64 z, f64 w)
2296: _x(x)
2297, _y(y)
2298, _z(z)
2299, _w(w)
2300{
2301}
2302
2303//---------------------------------------------------------------------------
2304// コンストラクタ
2306//---------------------------------------------------------------------------
2307GX_FORCE_INLINE GxVector4d::GxVector4d(const GxDouble4& double4)
2308: _x(double4._x)
2309, _y(double4._y)
2310, _z(double4._z)
2311, _w(double4._w)
2312{
2313}
2314
2315//---------------------------------------------------------------------------
2316// コンストラクタ
2318//---------------------------------------------------------------------------
2319GX_FORCE_INLINE GxVector4d::GxVector4d(const f64* pDoubleArray)
2320: _x(pDoubleArray[0])
2321, _y(pDoubleArray[1])
2322, _z(pDoubleArray[2])
2323, _w(pDoubleArray[3])
2324{
2325}
2326
2327//---------------------------------------------------------------------------
2328// コンストラクタ
2329//
2332//---------------------------------------------------------------------------
2333GX_FORCE_INLINE GxVector4d::GxVector4d(const GxVector3d& vector, f64 w)
2334: _x(vector._x)
2335, _y(vector._y)
2336, _z(vector._z)
2337, _w(w)
2338{
2339}
2340
2341//---------------------------------------------------------------------------
2342// コンストラクタ
2343//
2345//---------------------------------------------------------------------------
2346GX_FORCE_INLINE GxVector4d::GxVector4d(const GxColorHDR& color)
2347: _x(color._red)
2348, _y(color._green)
2349, _z(color._blue)
2350, _w(color._alpha)
2351{
2352}
2353
2354//---------------------------------------------------------------------------
2355// コピーコンストラクタ
2357//---------------------------------------------------------------------------
2358GX_FORCE_INLINE GxVector4d::GxVector4d(const GxVector4d& vector)
2359: _x(vector._x)
2360, _y(vector._y)
2361, _z(vector._z)
2362, _w(vector._w)
2363{
2364}
2365
2366//---------------------------------------------------------------------------
2367// 代入
2370//---------------------------------------------------------------------------
2371GX_FORCE_INLINE GxVector4d& GxVector4d::operator = (const GxVector3d& vector)
2372{
2373 _x = vector._x;
2374 _y = vector._y;
2375 _z = vector._z;
2376
2377 return *this;
2378}
2379
2380//---------------------------------------------------------------------------
2381// 代入
2384//---------------------------------------------------------------------------
2385GX_FORCE_INLINE GxVector4d& GxVector4d::operator = (const GxVector4d& vector)
2386{
2387 _x = vector._x;
2388 _y = vector._y;
2389 _z = vector._z;
2390 _w = vector._w;
2391 return *this;
2392}
2393
2394//---------------------------------------------------------------------------
2395// スカラ加算代入
2398//---------------------------------------------------------------------------
2399GX_FORCE_INLINE GxVector4d& GxVector4d::operator += (f64 scalar)
2400{
2401 addScalar(scalar);
2402 return *this;
2403}
2404
2405//---------------------------------------------------------------------------
2406// スカラ減算代入
2409//---------------------------------------------------------------------------
2410GX_FORCE_INLINE GxVector4d& GxVector4d::operator -= (f64 scalar)
2411{
2412 subScalar(scalar);
2413 return *this;
2414}
2415
2416//---------------------------------------------------------------------------
2417// スカラ乗算代入
2420//---------------------------------------------------------------------------
2421GX_FORCE_INLINE GxVector4d& GxVector4d::operator *= (f64 scalar)
2422{
2423 mulScalar(scalar);
2424 return *this;
2425}
2426
2427//---------------------------------------------------------------------------
2428// スカラ除算代入
2431//---------------------------------------------------------------------------
2432GX_FORCE_INLINE GxVector4d& GxVector4d::operator /= (f64 scalar)
2433{
2434 divScalar(scalar);
2435 return *this;
2436}
2437
2438//---------------------------------------------------------------------------
2439// ベクトル加算代入
2442//---------------------------------------------------------------------------
2443GX_FORCE_INLINE GxVector4d& GxVector4d::operator += (const GxVector4d& vector)
2444{
2445 addVector(vector);
2446 return *this;
2447}
2448
2449//---------------------------------------------------------------------------
2450// ベクトル減算代入
2453//---------------------------------------------------------------------------
2454GX_FORCE_INLINE GxVector4d& GxVector4d::operator -= (const GxVector4d& vector)
2455{
2456 subVector(vector);
2457 return *this;
2458}
2459
2460//---------------------------------------------------------------------------
2461// ベクトル乗算代入
2464//---------------------------------------------------------------------------
2465GX_FORCE_INLINE GxVector4d& GxVector4d::operator *= (const GxVector4d& vector)
2466{
2467 mulVector(vector);
2468 return *this;
2469}
2470
2471//---------------------------------------------------------------------------
2472// ベクトル除算代入
2475//---------------------------------------------------------------------------
2476GX_FORCE_INLINE GxVector4d& GxVector4d::operator /= (const GxVector4d& vector)
2477{
2478 divVector(vector);
2479 return *this;
2480}
2481
2482//---------------------------------------------------------------------------
2483// スカラ加算
2487//---------------------------------------------------------------------------
2488GX_FORCE_INLINE const GxVector4d operator + (const GxVector4d& vector, f64 scalar)
2489{
2490 GxVector4d result;
2491 return GxVector4d::getAddScalar(result, vector, scalar);
2492}
2493
2494//---------------------------------------------------------------------------
2495// スカラ減算
2499//---------------------------------------------------------------------------
2500GX_FORCE_INLINE const GxVector4d operator - (const GxVector4d& vector, f64 scalar)
2501{
2502 GxVector4d result;
2503 return GxVector4d::getSubScalar(result, vector, scalar);
2504}
2505
2506//---------------------------------------------------------------------------
2507// スカラ乗算
2511//---------------------------------------------------------------------------
2512GX_FORCE_INLINE const GxVector4d operator * (const GxVector4d& vector, f64 scalar)
2513{
2514 GxVector4d result;
2515 return GxVector4d::getMulScalar(result, vector, scalar);
2516}
2517
2518//---------------------------------------------------------------------------
2519// スカラ乗算
2523//---------------------------------------------------------------------------
2524GX_FORCE_INLINE const GxVector4d operator * (f64 scalar, const GxVector4d& vector)
2525{
2526 GxVector4d result;
2527 return GxVector4d::getMulScalar(result, vector, scalar);
2528}
2529
2530//---------------------------------------------------------------------------
2531// スカラ除算
2535//---------------------------------------------------------------------------
2536GX_FORCE_INLINE const GxVector4d operator / (const GxVector4d& vector, f64 scalar)
2537{
2538 GxVector4d result;
2539 return GxVector4d::getDivScalar(result, vector, scalar);
2540}
2541
2542//---------------------------------------------------------------------------
2543// ベクトル加算
2547//---------------------------------------------------------------------------
2548GX_FORCE_INLINE const GxVector4d operator + (const GxVector4d& vector0, const GxVector4d& vector1)
2549{
2550 GxVector4d result;
2551 return GxVector4d::getAddVector(result, vector0, vector1);
2552}
2553
2554//---------------------------------------------------------------------------
2555// ベクトル減算
2559//---------------------------------------------------------------------------
2560GX_FORCE_INLINE const GxVector4d operator - (const GxVector4d& vector0, const GxVector4d& vector1)
2561{
2562 GxVector4d result;
2563 return GxVector4d::getSubVector(result, vector0, vector1);
2564}
2565
2566//---------------------------------------------------------------------------
2567// ベクトル乗算
2571//---------------------------------------------------------------------------
2572GX_FORCE_INLINE const GxVector4d operator * (const GxVector4d& vector0, const GxVector4d& vector1)
2573{
2574 GxVector4d result;
2575 return GxVector4d::getMulVector(result, vector0, vector1);
2576}
2577
2578//---------------------------------------------------------------------------
2579// ベクトル除算
2583//---------------------------------------------------------------------------
2584GX_FORCE_INLINE const GxVector4d operator / (const GxVector4d& vector0, const GxVector4d& vector1)
2585{
2586 GxVector4d result;
2587 return GxVector4d::getDivVector(result, vector0, vector1);
2588}
2589
2590//---------------------------------------------------------------------------
2591// 一致
2595//---------------------------------------------------------------------------
2596GX_FORCE_INLINE b32 operator == (const GxVector4d& vector0, const GxVector4d& vector1)
2597{
2598 return (vector0._x == vector1._x) && (vector0._y == vector1._y) && (vector0._z == vector1._z) && (vector0._w == vector1._w);
2599}
2600
2601//---------------------------------------------------------------------------
2602// 不一致
2606//---------------------------------------------------------------------------
2607GX_FORCE_INLINE b32 operator != (const GxVector4d& vector0, const GxVector4d& vector1)
2608{
2609 return (vector0._x != vector1._x) || (vector0._y != vector1._y) || (vector0._z != vector1._z) || (vector0._w != vector1._w);
2610}
2611
2612//---------------------------------------------------------------------------
2613// const配列
2616//---------------------------------------------------------------------------
2617GX_FORCE_INLINE const f64& GxVector4d::operator[](u32 i) const
2618{
2619 return (&_x)[i];
2620}
2621
2622//---------------------------------------------------------------------------
2623// 配列
2626//---------------------------------------------------------------------------
2627GX_FORCE_INLINE f64& GxVector4d::operator[](u32 i)
2628{
2629 return (&_x)[i];
2630}
2631
2632//---------------------------------------------------------------------------
2633// ゼロベクトル判定
2635//---------------------------------------------------------------------------
2636GX_FORCE_INLINE b32 GxVector4d::isZeroVector(void) const
2637{
2638 return (getLengthSquare() <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE);
2639}
2640
2641//---------------------------------------------------------------------------
2642// 長さを取得
2644//---------------------------------------------------------------------------
2645GX_FORCE_INLINE f64 GxVector4d::getLength(void) const
2646{
2648}
2649
2650//---------------------------------------------------------------------------
2651// 長さの2乗を取得
2653//---------------------------------------------------------------------------
2654GX_FORCE_INLINE f64 GxVector4d::getLengthSquare(void) const
2655{
2656 return _x * _x + _y * _y + _z * _z + _w * _w;
2657}
2658
2659//---------------------------------------------------------------------------
2660// 長さを設定
2661//
2663//---------------------------------------------------------------------------
2664GX_FORCE_INLINE void GxVector4d::setLength(f64 length)
2665{
2666 auto oldLength = getLength();
2667
2668#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2669 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < oldLength * oldLength, "ゼロベクトルに長さを設定しようとしました");
2670
2671 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2672 if (oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
2673 {
2674 oldLength = 1.0;
2675 }
2676#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2677 if( oldLength * oldLength <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
2678 {
2679 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
2680 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
2681 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルに長さを設定しようとしました");
2682
2683 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2684 oldLength = 1.0;
2685 }
2686#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2687
2688 const auto scale = length / oldLength;
2689
2690 _x *= scale;
2691 _y *= scale;
2692 _z *= scale;
2693 _w *= scale;
2694}
2695
2696//---------------------------------------------------------------------------
2697// 長さを設定(長さ0に対応)
2698//
2700//---------------------------------------------------------------------------
2701GX_FORCE_INLINE void GxVector4d::setLengthEx(f64 length)
2702{
2703 const auto lengthSquare = getLengthSquare();
2704
2705 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
2706 {
2707 const auto scale = length / GxMath::getSqrt(lengthSquare);
2708
2709 _x *= scale;
2710 _y *= scale;
2711 _z *= scale;
2712 _w *= scale;
2713 }
2714 else
2715 {
2716 _x = 0.0;
2717 _y = 0.0;
2718 _z = 0.0;
2719 _w = 0.0;
2720 }
2721}
2722
2723//---------------------------------------------------------------------------
2724// 正規化ベクトルを取得
2726//---------------------------------------------------------------------------
2727GX_FORCE_INLINE GxVector4d GxVector4d::getNormalize(void) const
2728{
2729 auto length = getLength();
2730
2731#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2732 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
2733
2734 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2735 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
2736 {
2737 length = 1.0;
2738 }
2739#else // GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2740 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
2741 {
2742 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
2743 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
2744 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
2745
2746 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2747 length = 1.0;
2748 }
2749#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2750
2751 const auto inverseLength = 1.0 / length;
2752
2753 return GxVector4d(_x * inverseLength, _y * inverseLength, _z * inverseLength, _w * inverseLength);
2754}
2755
2756//---------------------------------------------------------------------------
2757// 正規化ベクトルを取得(長さ0に対応)
2759//---------------------------------------------------------------------------
2760GX_FORCE_INLINE GxVector4d GxVector4d::getNormalizeEx(void) const
2761{
2762 const auto lengthSquare = getLengthSquare();
2763
2764 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
2765 {
2766 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
2767 return GxVector4d(_x * inverseLength, _y * inverseLength, _z * inverseLength, _w * inverseLength);
2768 }
2769 return GxVector4d::ZERO;
2770}
2771
2772//---------------------------------------------------------------------------
2773// スカラ加算を取得
2778//---------------------------------------------------------------------------
2779GX_FORCE_INLINE const GxVector4d& GxVector4d::getAddScalar(GxVector4d& dst, const GxVector4d& vector, f64 scalar)
2780{
2781 dst._x = vector._x + scalar;
2782 dst._y = vector._y + scalar;
2783 dst._z = vector._z + scalar;
2784 dst._w = vector._w + scalar;
2785
2786 return dst;
2787}
2788
2789//---------------------------------------------------------------------------
2790// スカラ減算を取得
2795//---------------------------------------------------------------------------
2796GX_FORCE_INLINE const GxVector4d& GxVector4d::getSubScalar(GxVector4d& dst, const GxVector4d& vector, f64 scalar)
2797{
2798 dst._x = vector._x - scalar;
2799 dst._y = vector._y - scalar;
2800 dst._z = vector._z - scalar;
2801 dst._w = vector._w - scalar;
2802
2803 return dst;
2804}
2805
2806//---------------------------------------------------------------------------
2807// スカラ乗算を取得
2812//---------------------------------------------------------------------------
2813GX_FORCE_INLINE const GxVector4d& GxVector4d::getMulScalar(GxVector4d& dst, const GxVector4d& vector, f64 scalar)
2814{
2815 dst._x = vector._x * scalar;
2816 dst._y = vector._y * scalar;
2817 dst._z = vector._z * scalar;
2818 dst._w = vector._w * scalar;
2819
2820 return dst;
2821}
2822
2823//---------------------------------------------------------------------------
2824// スカラ除算を取得
2829//---------------------------------------------------------------------------
2830GX_FORCE_INLINE const GxVector4d& GxVector4d::getDivScalar(GxVector4d& dst, const GxVector4d& vector, f64 scalar)
2831{
2832 auto inverseScalar = 1.0 / scalar;
2833
2834 dst._x = vector._x * inverseScalar;
2835 dst._y = vector._y * inverseScalar;
2836 dst._z = vector._z * inverseScalar;
2837 dst._w = vector._w * inverseScalar;
2838
2839 return dst;
2840}
2841
2842//---------------------------------------------------------------------------
2843// ベクトル加算を取得
2848//---------------------------------------------------------------------------
2849GX_FORCE_INLINE const GxVector4d& GxVector4d::getAddVector(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
2850{
2851 dst._x = vector0._x + vector1._x;
2852 dst._y = vector0._y + vector1._y;
2853 dst._z = vector0._z + vector1._z;
2854 dst._w = vector0._w + vector1._w;
2855
2856 return dst;
2857}
2858
2859//---------------------------------------------------------------------------
2860// ベクトル減算を取得
2865//---------------------------------------------------------------------------
2866GX_FORCE_INLINE const GxVector4d& GxVector4d::getSubVector(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
2867{
2868 dst._x = vector0._x - vector1._x;
2869 dst._y = vector0._y - vector1._y;
2870 dst._z = vector0._z - vector1._z;
2871 dst._w = vector0._w - vector1._w;
2872
2873 return dst;
2874}
2875
2876//---------------------------------------------------------------------------
2877// ベクトル乗算を取得
2882//---------------------------------------------------------------------------
2883GX_FORCE_INLINE const GxVector4d& GxVector4d::getMulVector(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
2884{
2885 dst._x = vector0._x * vector1._x;
2886 dst._y = vector0._y * vector1._y;
2887 dst._z = vector0._z * vector1._z;
2888 dst._w = vector0._w * vector1._w;
2889
2890 return dst;
2891}
2892
2893//---------------------------------------------------------------------------
2894// ベクトル除算を取得
2899//---------------------------------------------------------------------------
2900GX_FORCE_INLINE const GxVector4d& GxVector4d::getDivVector(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
2901{
2902 dst._x = vector0._x / vector1._x;
2903 dst._y = vector0._y / vector1._y;
2904 dst._z = vector0._z / vector1._z;
2905 dst._w = vector0._w / vector1._w;
2906
2907 return dst;
2908}
2909
2910//---------------------------------------------------------------------------
2911// 正規化ベクトルを取得
2915//---------------------------------------------------------------------------
2916GX_FORCE_INLINE const GxVector4d& GxVector4d::getNormalize(GxVector4d& dst, const GxVector4d& vector)
2917{
2918 auto length = vector.getLength();
2919
2920#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2921 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length* length, "ゼロベクトルを正規化しようとしました");
2922
2923 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2924 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
2925 {
2926 length = 1.0;
2927 }
2928#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2929 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
2930 {
2931 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
2932 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
2933 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
2934
2935 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
2936 length = 1.0;
2937 }
2938#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
2939
2940 const auto inverseLength = 1.0 / length;
2941
2942 dst._x = vector._x * inverseLength;
2943 dst._y = vector._y * inverseLength;
2944 dst._z = vector._z * inverseLength;
2945 dst._w = vector._w * inverseLength;
2946
2947 return dst;
2948}
2949
2950//---------------------------------------------------------------------------
2951// 正規化ベクトルを取得(長さ0に対応)
2955//---------------------------------------------------------------------------
2956GX_FORCE_INLINE const GxVector4d& GxVector4d::getNormalizeEx(GxVector4d& dst, const GxVector4d& vector)
2957{
2958 const auto lengthSquare = vector.getLengthSquare();
2959
2960 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
2961 {
2962 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
2963
2964 dst._x = vector._x * inverseLength;
2965 dst._y = vector._y * inverseLength;
2966 dst._z = vector._z * inverseLength;
2967 dst._w = vector._w * inverseLength;
2968 }
2969 else
2970 {
2971 dst._x = 0.0;
2972 dst._y = 0.0;
2973 dst._z = 0.0;
2974 dst._w = 0.0;
2975 }
2976
2977 return dst;
2978}
2979
2980//---------------------------------------------------------------------------
2981// 内積を取得
2985//---------------------------------------------------------------------------
2986GX_FORCE_INLINE f64 GxVector4d::getDot(const GxVector4d& vector0, const GxVector4d& vector1)
2987{
2988 return vector0._x * vector1._x + vector0._y * vector1._y + vector0._z * vector1._z + vector0._w * vector1._w;
2989}
2990
2991//---------------------------------------------------------------------------
2992// 要素毎に最小値を選択
2996//---------------------------------------------------------------------------
2997GX_FORCE_INLINE GxVector4d GxVector4d::getMinimum(const GxVector4d& vector0, const GxVector4d& vector1)
2998{
2999 return GxVector4d(vector0._x < vector1._x ? vector0._x : vector1._x,
3000 vector0._y < vector1._y ? vector0._y : vector1._y,
3001 vector0._z < vector1._z ? vector0._z : vector1._z,
3002 vector0._w < vector1._w ? vector0._w : vector1._w);
3003}
3004
3005//---------------------------------------------------------------------------
3006// 要素毎に最小値を選択
3011//---------------------------------------------------------------------------
3012GX_FORCE_INLINE const GxVector4d& GxVector4d::getMinimum(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
3013{
3014 dst._x = vector0._x < vector1._x ? vector0._x : vector1._x;
3015 dst._y = vector0._y < vector1._y ? vector0._y : vector1._y;
3016 dst._z = vector0._z < vector1._z ? vector0._z : vector1._z;
3017 dst._w = vector0._w < vector1._w ? vector0._w : vector1._w;
3018
3019 return dst;
3020}
3021
3022//---------------------------------------------------------------------------
3023// 要素毎に最大値を選択
3027//---------------------------------------------------------------------------
3028GX_FORCE_INLINE GxVector4d GxVector4d::getMaximum(const GxVector4d& vector0, const GxVector4d& vector1)
3029{
3030 return GxVector4d(vector0._x > vector1._x ? vector0._x : vector1._x,
3031 vector0._y > vector1._y ? vector0._y : vector1._y,
3032 vector0._z > vector1._z ? vector0._z : vector1._z,
3033 vector0._w > vector1._w ? vector0._w : vector1._w);
3034}
3035
3036//---------------------------------------------------------------------------
3037// 要素毎に最大値を選択
3042//---------------------------------------------------------------------------
3043GX_FORCE_INLINE const GxVector4d& GxVector4d::getMaximum(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1)
3044{
3045 dst._x = vector0._x > vector1._x ? vector0._x : vector1._x;
3046 dst._y = vector0._y > vector1._y ? vector0._y : vector1._y;
3047 dst._z = vector0._z > vector1._z ? vector0._z : vector1._z;
3048 dst._w = vector0._w > vector1._w ? vector0._w : vector1._w;
3049
3050 return dst;
3051}
3052
3053//---------------------------------------------------------------------------
3054// 線形補間
3059//---------------------------------------------------------------------------
3060GX_FORCE_INLINE GxVector4d GxVector4d::getLerp(const GxVector4d& vector0, const GxVector4d& vector1, f64 t)
3061{
3062 return GxVector4d(vector0._x + (vector1._x - vector0._x) * t,
3063 vector0._y + (vector1._y - vector0._y) * t,
3064 vector0._z + (vector1._z - vector0._z) * t,
3065 vector0._w + (vector1._w - vector0._w) * t);
3066}
3067
3068//---------------------------------------------------------------------------
3069// 線形補間
3075//---------------------------------------------------------------------------
3076GX_FORCE_INLINE const GxVector4d& GxVector4d::getLerp(GxVector4d& dst, const GxVector4d& vector0, const GxVector4d& vector1, f64 t)
3077{
3078 dst._x = vector0._x + (vector1._x - vector0._x) * t;
3079 dst._y = vector0._y + (vector1._y - vector0._y) * t;
3080 dst._z = vector0._z + (vector1._z - vector0._z) * t;
3081 dst._w = vector0._w + (vector1._w - vector0._w) * t;
3082
3083 return dst;
3084}
3085
3086//---------------------------------------------------------------------------
3087// スカラ加算
3090//---------------------------------------------------------------------------
3091GX_FORCE_INLINE const GxVector4d& GxVector4d::addScalar(f64 scalar)
3092{
3093 _x += scalar;
3094 _y += scalar;
3095 _z += scalar;
3096 _w += scalar;
3097
3098 return *this;
3099}
3100
3101//---------------------------------------------------------------------------
3102// スカラ減算
3105//---------------------------------------------------------------------------
3106GX_FORCE_INLINE const GxVector4d& GxVector4d::subScalar(f64 scalar)
3107{
3108 _x -= scalar;
3109 _y -= scalar;
3110 _z -= scalar;
3111 _w -= scalar;
3112
3113 return *this;
3114}
3115
3116//---------------------------------------------------------------------------
3117// スカラ乗算
3120//---------------------------------------------------------------------------
3121GX_FORCE_INLINE const GxVector4d& GxVector4d::mulScalar(f64 scalar)
3122{
3123 _x *= scalar;
3124 _y *= scalar;
3125 _z *= scalar;
3126 _w *= scalar;
3127
3128 return *this;
3129}
3130
3131//---------------------------------------------------------------------------
3132// スカラ除算
3135//---------------------------------------------------------------------------
3136GX_FORCE_INLINE const GxVector4d& GxVector4d::divScalar(f64 scalar)
3137{
3138 auto inverseScalar = 1.0 / scalar;
3139
3140 _x *= inverseScalar;
3141 _y *= inverseScalar;
3142 _z *= inverseScalar;
3143 _w *= inverseScalar;
3144
3145 return *this;
3146}
3147
3148//---------------------------------------------------------------------------
3149// ベクトル加算
3152//---------------------------------------------------------------------------
3153GX_FORCE_INLINE const GxVector4d& GxVector4d::addVector(const GxVector4d& vector)
3154{
3155 _x += vector._x;
3156 _y += vector._y;
3157 _z += vector._z;
3158 _w += vector._w;
3159
3160 return *this;
3161}
3162
3163//---------------------------------------------------------------------------
3164// ベクトル減算
3167//---------------------------------------------------------------------------
3168GX_FORCE_INLINE const GxVector4d& GxVector4d::subVector(const GxVector4d& vector)
3169{
3170 _x -= vector._x;
3171 _y -= vector._y;
3172 _z -= vector._z;
3173 _w -= vector._w;
3174
3175 return *this;
3176}
3177
3178//---------------------------------------------------------------------------
3179// ベクトル乗算
3182//---------------------------------------------------------------------------
3183GX_FORCE_INLINE const GxVector4d& GxVector4d::mulVector(const GxVector4d& vector)
3184{
3185 _x *= vector._x;
3186 _y *= vector._y;
3187 _z *= vector._z;
3188 _w *= vector._w;
3189
3190 return *this;
3191}
3192
3193//---------------------------------------------------------------------------
3194// ベクトル除算
3197//---------------------------------------------------------------------------
3198GX_FORCE_INLINE const GxVector4d& GxVector4d::divVector(const GxVector4d& vector)
3199{
3200 _x /= vector._x;
3201 _y /= vector._y;
3202 _z /= vector._z;
3203 _w /= vector._w;
3204
3205 return *this;
3206}
3207
3208//---------------------------------------------------------------------------
3209// 正規化する
3211//---------------------------------------------------------------------------
3212GX_FORCE_INLINE const GxVector4d& GxVector4d::normalize(void)
3213{
3214 auto length = getLength();
3215
3216#if GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
3217 GX_ERROR(GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < length * length, "ゼロベクトルを正規化しようとしました");
3218
3219 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
3220 if (length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE)
3221 {
3222 length = 1.0;
3223 }
3224#else //GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
3225 if( length * length <= GX_VECTOR_ZERO_VECTOR_CHECK_VALUE )
3226 {
3227 GX_TRACE(GX_TRACE_CATEGORY_CORE, "%s(%d)", __FILE__, __LINE__);
3228 GX_TRACE(GX_TRACE_CATEGORY_CORE, "[%s]", __FUNCTION__);
3229 GX_TRACE(GX_TRACE_CATEGORY_CORE, "ゼロベクトルを正規化しようとしました");
3230
3231 //このまま進んでしまうと0除算が発生したまま処理が進みINF等になるため1.0に補正
3232 length = 1.0;
3233 }
3234#endif // !GX_VECTOR_ZERO_DIVIDE_WARNING_ENABLE
3235
3236 const auto inverseLength = 1.0 / length;
3237 _x *= inverseLength;
3238 _y *= inverseLength;
3239 _z *= inverseLength;
3240 _w *= inverseLength;
3241
3242 return *this;
3243}
3244
3245//---------------------------------------------------------------------------
3246// 正規化する(長さ0に対応)
3248//---------------------------------------------------------------------------
3249GX_FORCE_INLINE const GxVector4d& GxVector4d::normalizeEx(void)
3250{
3251 const auto lengthSquare = getLengthSquare();
3252
3253 if( GX_VECTOR_ZERO_VECTOR_CHECK_VALUE < lengthSquare )
3254 {
3255 const auto inverseLength = 1.0 / GxMath::getSqrt(lengthSquare);
3256 _x *= inverseLength;
3257 _y *= inverseLength;
3258 _z *= inverseLength;
3259 _w *= inverseLength;
3260 }
3261 else
3262 {
3263 _x = 0.0;
3264 _y = 0.0;
3265 _z = 0.0;
3266 _w = 0.0;
3267 }
3268
3269 return *this;
3270}
3271
3272#undef GX_VECTOR_ZERO_VECTOR_CHECK_VALUE
3273
3274GX_CORE_NAMESPACE_END()
GX_FORCE_INLINE b32 operator==(const GxVector2d &vector0, const GxVector2d &vector1)
Definition GxVectord.inl:283
GX_FORCE_INLINE b32 operator!=(const GxVector2d &vector0, const GxVector2d &vector1)
Definition GxVectord.inl:294
GX_FORCE_INLINE const GxVector2d operator-(const GxVector2d &vector, f64 scalar)
Definition GxVectord.inl:187
GX_FORCE_INLINE const GxVector2d operator+(const GxVector2d &vector, f64 scalar)
Definition GxVectord.inl:175
GX_FORCE_INLINE const GxVector2d operator/(const GxVector2d &vector, f64 scalar)
Definition GxVectord.inl:223
GX_FORCE_INLINE const GxVector2d operator*(const GxVector2d &vector, f64 scalar)
Definition GxVectord.inl:199
static GX_FORCE_INLINE T getClamp(const T value, const T min, const T max)
最小値・最大値で切り落とす
Definition GxMath.h:170
static GX_FORCE_INLINE f32 getCos(const f32 radian)
余弦を取得(f32)
Definition GxMath.h:212
static GX_FORCE_INLINE f32 getACos(const f32 value)
逆余弦を取得(f32)
Definition GxMath.h:233
static GX_FORCE_INLINE f32 getATan2(const f32 valueY, const f32 valueX)
逆正接を取得(f32)
Definition GxMath.h:247
static GX_FORCE_INLINE f32 getSqrt(const f32 value)
平方根を取得(f32)
Definition GxMath.h:259
色(HDR)
Definition GxColor.h:241
2次元浮動小数点数(倍精度)クラス
Definition GxStruct.h:207
3次元浮動小数点数(倍精度)クラス
Definition GxStruct.h:276
4次元浮動小数点数(倍精度)クラス
Definition GxStruct.h:338
座標
Definition GxStruct.h:867
2次元ベクトル(倍精度)
Definition GxVectord.h:25
static GX_FORCE_INLINE GxVector2d getMaximum(const GxVector2d &vector0, const GxVector2d &vector1)
要素毎に最大値を選択
Definition GxVectord.inl:717
GX_FORCE_INLINE const GxVector2d & mulVector(const GxVector2d &vector)
ベクトル乗算
Definition GxVectord.inl:852
static GX_FORCE_INLINE f64 getDot(const GxVector2d &vector0, const GxVector2d &vector1)
内積を取得
Definition GxVectord.inl:648
GX_FORCE_INLINE void setLength(f64 length)
長さを設定
Definition GxVectord.inl:350
static GX_FORCE_INLINE const GxVector2d & getDivScalar(GxVector2d &dst, const GxVector2d &vector, f64 scalar)
スカラ除算を取得
Definition GxVectord.inl:508
static GX_FORCE_INLINE const GxVector2d & getAddVector(GxVector2d &dst, const GxVector2d &vector0, const GxVector2d &vector1)
ベクトル加算を取得
Definition GxVectord.inl:525
GX_FORCE_INLINE const GxVector2d & normalize(void)
正規化する
Definition GxVectord.inl:877
static GX_FORCE_INLINE const GxVector2d & getDivVector(GxVector2d &dst, const GxVector2d &vector0, const GxVector2d &vector1)
ベクトル除算を取得
Definition GxVectord.inl:570
static GX_FORCE_INLINE const GxVector2d & getAddScalar(GxVector2d &dst, const GxVector2d &vector, f64 scalar)
スカラ加算を取得
Definition GxVectord.inl:463
GxVector2d(void)
デフォルトコンストラクタ
Definition GxVectord.h:55
static GX_FORCE_INLINE const GxVector2d & getMulScalar(GxVector2d &dst, const GxVector2d &vector, f64 scalar)
スカラ乗算を取得
Definition GxVectord.inl:493
GX_FORCE_INLINE const GxVector2d & divScalar(f64 scalar)
スカラ除算
Definition GxVectord.inl:811
GX_FORCE_INLINE const GxVector2d & normalizeEx(void)
正規化する(長さ0に対応)
Definition GxVectord.inl:913
static GX_FORCE_INLINE GxVector2d getLerp(const GxVector2d &vector0, const GxVector2d &vector1, f64 t)
線形補間
Definition GxVectord.inl:745
GX_FORCE_INLINE const GxVector2d & addVector(const GxVector2d &vector)
ベクトル加算
Definition GxVectord.inl:826
GX_FORCE_INLINE const GxVector2d & subScalar(f64 scalar)
スカラ減算
Definition GxVectord.inl:785
static GX_FORCE_INLINE const GxVector2d & getMulVector(GxVector2d &dst, const GxVector2d &vector0, const GxVector2d &vector1)
ベクトル乗算を取得
Definition GxVectord.inl:555
f64 _y
Y値
Definition GxVectord.h:226
GX_FORCE_INLINE GxVector2d & operator+=(f64 scalar)
スカラ加算代入
Definition GxVectord.inl:86
GX_FORCE_INLINE const GxVector2d & subVector(const GxVector2d &vector)
ベクトル減算
Definition GxVectord.inl:839
f64 _x
X値
Definition GxVectord.h:225
static GX_FORCE_INLINE f64 getAngle(const GxVector2d &vector0, const GxVector2d &vector1)
角度差を取得(符号つき radian)
Definition GxVectord.inl:671
GX_FORCE_INLINE GxVector2d & operator*=(f64 scalar)
スカラ乗算代入
Definition GxVectord.inl:108
GX_FORCE_INLINE GxVector2d & operator=(const GxVector2d &vector)
代入
Definition GxVectord.inl:74
GX_FORCE_INLINE GxVector2d & operator-=(f64 scalar)
スカラ減算代入
Definition GxVectord.inl:97
static const GxVector2d ZERO
(0, 0)
Definition GxVectord.h:36
GX_FORCE_INLINE GxVector2d getNormalizeEx(void) const
正規化ベクトルを取得(長さ0に対応)
Definition GxVectord.inl:440
GX_FORCE_INLINE b32 isZeroVector(void) const
ゼロベクトルかを取得
Definition GxVectord.inl:323
GX_FORCE_INLINE const GxVector2d & mulScalar(f64 scalar)
スカラ乗算
Definition GxVectord.inl:798
GX_FORCE_INLINE f64 getLength(void) const
長さを取得
Definition GxVectord.inl:332
GX_FORCE_INLINE const GxVector2d & addScalar(f64 scalar)
スカラ加算
Definition GxVectord.inl:772
GX_FORCE_INLINE GxVector2d & operator/=(f64 scalar)
スカラ除算代入
Definition GxVectord.inl:119
static GX_FORCE_INLINE GxVector2d getMinimum(const GxVector2d &vector0, const GxVector2d &vector1)
要素毎に最小値を選択
Definition GxVectord.inl:690
GX_FORCE_INLINE const GxVector2d & divVector(const GxVector2d &vector)
ベクトル除算
Definition GxVectord.inl:865
GX_FORCE_INLINE GxVector2d getNormalize(void) const
正規化ベクトルを取得
Definition GxVectord.inl:407
GX_FORCE_INLINE f64 getLengthSquare(void) const
長さの2乗を取得
Definition GxVectord.inl:341
static GX_FORCE_INLINE const GxVector2d & getSubVector(GxVector2d &dst, const GxVector2d &vector0, const GxVector2d &vector1)
ベクトル減算を取得
Definition GxVectord.inl:540
static GX_FORCE_INLINE const GxVector2d & getSubScalar(GxVector2d &dst, const GxVector2d &vector, f64 scalar)
スカラ減算を取得
Definition GxVectord.inl:478
GX_FORCE_INLINE const f64 & operator[](u32 i) const
const配列
Definition GxVectord.inl:304
GX_FORCE_INLINE void setLengthEx(f64 length)
長さを設定(長さ0に対応)
Definition GxVectord.inl:385
static GX_FORCE_INLINE f64 getCross(const GxVector2d &vector0, const GxVector2d &vector1)
外積を取得
Definition GxVectord.inl:659
3次元ベクトル(倍精度)
Definition GxVectord.h:235
GX_FORCE_INLINE GxVector3d & operator-=(f64 scalar)
スカラ減算代入
Definition GxVectord.inl:1046
GX_FORCE_INLINE const GxVector3d & divScalar(f64 scalar)
スカラ除算
Definition GxVectord.inl:2155
GX_FORCE_INLINE GxVector3d getYZ(void) const
YZ要素のベクトルを取得
Definition GxVectord.inl:1340
GX_FORCE_INLINE const GxVector3d & addScalar(f64 scalar)
スカラ加算
Definition GxVectord.inl:2113
static GX_FORCE_INLINE GxVector3d getLerp(const GxVector3d &vector0, const GxVector3d &vector1, f64 t)
線形補間
Definition GxVectord.inl:1928
GX_FORCE_INLINE const GxVector3d & normalizeEx(void)
正規化する(長さ0に対応)
Definition GxVectord.inl:2263
static GX_FORCE_INLINE GxVector3d getMinimum(const GxVector3d &vector0, const GxVector3d &vector1)
要素毎に最小値を選択
Definition GxVectord.inl:1869
GX_FORCE_INLINE const GxVector3d & mulScalar(f64 scalar)
スカラ乗算
Definition GxVectord.inl:2141
GX_FORCE_INLINE const GxVector3d & mulVector(const GxVector3d &vector)
ベクトル乗算
Definition GxVectord.inl:2199
f64 _y
Y値
Definition GxVectord.h:487
static GX_FORCE_INLINE GxVector3d getSegmentPosition(const GxVector3d &position, const GxVector3d &startPosition, const GxVector3d &endPosition)
指定した点を線分上に下ろした点を取得
Definition GxVectord.inl:2030
GX_FORCE_INLINE const GxVector3d & normalize(void)
正規化する
Definition GxVectord.inl:2226
static GX_FORCE_INLINE f64 getAngle(const GxVector3d &vector0, const GxVector3d &vector1)
角度差を取得(符号なし radian)
Definition GxVectord.inl:1825
GX_FORCE_INLINE void setYZ(const GxVector3d &vector)
YZ要素のベクトルを設定
Definition GxVectord.inl:1363
static GX_FORCE_INLINE const GxVector3d & getMulVector(GxVector3d &dst, const GxVector3d &vector0, const GxVector3d &vector1)
ベクトル乗算を取得
Definition GxVectord.inl:1620
GX_FORCE_INLINE f64 getLengthSquare(void) const
長さの2乗を取得
Definition GxVectord.inl:1391
GX_FORCE_INLINE void setLengthEx(f64 length)
長さを設定(長さ0に対応)
Definition GxVectord.inl:1436
static GX_FORCE_INLINE GxVector3d getLinePosition(const GxVector3d &position, const GxVector3d &linePosition0, const GxVector3d &linePosition1)
指定した点を直線上に下ろした点を取得
Definition GxVectord.inl:2000
static GX_FORCE_INLINE const GxVector3d & getMulScalar(GxVector3d &dst, const GxVector3d &vector, f64 scalar)
スカラ乗算を取得
Definition GxVectord.inl:1554
static GX_FORCE_INLINE const GxVector3d & getSubVector(GxVector3d &dst, const GxVector3d &vector0, const GxVector3d &vector1)
ベクトル減算を取得
Definition GxVectord.inl:1604
GX_FORCE_INLINE const GxVector3d & subScalar(f64 scalar)
スカラ減算
Definition GxVectord.inl:2127
static GX_FORCE_INLINE const GxVector3d & getAddScalar(GxVector3d &dst, const GxVector3d &vector, f64 scalar)
スカラ加算を取得
Definition GxVectord.inl:1522
GxVector3d(void)
デフォルトコンストラクタ
Definition GxVectord.h:267
GX_FORCE_INLINE GxVector3d & operator*=(f64 scalar)
スカラ乗算代入
Definition GxVectord.inl:1057
f64 _x
X値
Definition GxVectord.h:486
GX_FORCE_INLINE GxVector3d getNormalizeEx(void) const
正規化ベクトルを取得(長さ0に対応)
Definition GxVectord.inl:1493
GX_FORCE_INLINE const f64 & operator[](u32 i) const
const配列
Definition GxVectord.inl:1253
GX_FORCE_INLINE f64 getLength(void) const
長さを取得
Definition GxVectord.inl:1382
GX_FORCE_INLINE b32 isZeroVector(void) const
ゼロベクトルかを取得
Definition GxVectord.inl:1373
static GX_FORCE_INLINE f64 getDistanceSquare(const GxVector3d &vector0, const GxVector3d &vector1)
距離の2乗を取得
Definition GxVectord.inl:1809
GX_FORCE_INLINE void setXZ(const GxVector3d &vector)
XZ要素のベクトルを設定
Definition GxVectord.inl:1330
GX_FORCE_INLINE GxVector3d getNormalize(void) const
正規化ベクトルを取得
Definition GxVectord.inl:1460
static GX_FORCE_INLINE const GxVector3d & getAddVector(GxVector3d &dst, const GxVector3d &vector0, const GxVector3d &vector1)
ベクトル加算を取得
Definition GxVectord.inl:1588
static GX_FORCE_INLINE GxVector3d getCrossVector(const GxVector3d &vector)
直交する単位ベクトルを取得
Definition GxVectord.inl:1757
f64 _z
Z値
Definition GxVectord.h:488
GX_FORCE_INLINE GxVector3d getXZ(void) const
XZ要素のベクトルを取得
Definition GxVectord.inl:1306
static GX_FORCE_INLINE f64 getDot(const GxVector3d &vector0, const GxVector3d &vector1)
内積を取得
Definition GxVectord.inl:1718
GX_FORCE_INLINE void setXY(const GxVector3d &vector)
XY要素のベクトルを設定
Definition GxVectord.inl:1296
static GX_FORCE_INLINE f64 getLineParam(const GxVector3d &checkPosition, const GxVector3d &startPosition, const GxVector3d &endPosition)
指定した点が線分上のどこに位置するかのパラメータを返す
Definition GxVectord.inl:1962
static GX_FORCE_INLINE b32 isSameDirectionLessEqual(const GxVector3d &vector0, const GxVector3d &vector1, f64 limitRadian=PI/2.0)
ベクトルが同じ方向を向いているか(ラジアン指定/指定値以内なら(==も含む)同じ方向)
Definition GxVectord.inl:2045
static GX_FORCE_INLINE b32 isSameDirectionLessThan(const GxVector3d &vector0, const GxVector3d &vector1, f64 limitRadian=PI/2.0)
ベクトルが同じ方向を向いているか(ラジアン指定/指定値より小さければ(==は含まない)同じ方向)
Definition GxVectord.inl:2080
static GX_FORCE_INLINE const GxVector3d & getDivVector(GxVector3d &dst, const GxVector3d &vector0, const GxVector3d &vector1)
ベクトル除算を取得
Definition GxVectord.inl:1636
GX_FORCE_INLINE GxVector3d & operator=(const GxVector3d &vector)
代入
Definition GxVectord.inl:1022
static GX_FORCE_INLINE GxVector3d getMaximum(const GxVector3d &vector0, const GxVector3d &vector1)
要素毎に最大値を選択
Definition GxVectord.inl:1898
GX_FORCE_INLINE const GxVector3d & subVector(const GxVector3d &vector)
ベクトル減算
Definition GxVectord.inl:2185
static GX_FORCE_INLINE const GxVector3d & getSubScalar(GxVector3d &dst, const GxVector3d &vector, f64 scalar)
スカラ減算を取得
Definition GxVectord.inl:1538
GX_FORCE_INLINE GxVector3d & operator/=(f64 scalar)
スカラ除算代入
Definition GxVectord.inl:1068
static GX_FORCE_INLINE GxVector3d getCross(const GxVector3d &vector0, const GxVector3d &vector1)
外積を取得
Definition GxVectord.inl:1729
GX_FORCE_INLINE void setLength(f64 length)
長さを設定
Definition GxVectord.inl:1400
static GX_FORCE_INLINE f64 getDistance(const GxVector3d &vector0, const GxVector3d &vector1)
距離を取得
Definition GxVectord.inl:1798
GX_FORCE_INLINE const GxVector3d & divVector(const GxVector3d &vector)
ベクトル除算
Definition GxVectord.inl:2213
GX_FORCE_INLINE GxVector3d & operator+=(f64 scalar)
スカラ加算代入
Definition GxVectord.inl:1035
GX_FORCE_INLINE const GxVector3d & addVector(const GxVector3d &vector)
ベクトル加算
Definition GxVectord.inl:2171
GX_FORCE_INLINE GxVector3d getXY(void) const
XY要素のベクトルを取得
Definition GxVectord.inl:1272
static GX_FORCE_INLINE const GxVector3d & getDivScalar(GxVector3d &dst, const GxVector3d &vector, f64 scalar)
スカラ除算を取得
Definition GxVectord.inl:1570
4次元ベクトル(倍精度)
Definition GxVectord.h:497
static const GxVector4d ZERO
(0, 0, 0, 0)
Definition GxVectord.h:508
GX_FORCE_INLINE const GxVector4d & normalizeEx(void)
正規化する(長さ0に対応)
Definition GxVectord.inl:3249
GX_FORCE_INLINE GxVector4d getNormalize(void) const
正規化ベクトルを取得
Definition GxVectord.inl:2727
static GX_FORCE_INLINE const GxVector4d & getAddScalar(GxVector4d &dst, const GxVector4d &vector, f64 scalar)
スカラ加算を取得
Definition GxVectord.inl:2779
static GX_FORCE_INLINE GxVector4d getMinimum(const GxVector4d &vector0, const GxVector4d &vector1)
要素毎に最小値を選択
Definition GxVectord.inl:2997
GX_FORCE_INLINE GxVector4d & operator+=(f64 scalar)
スカラ加算代入
Definition GxVectord.inl:2399
GX_FORCE_INLINE GxVector4d & operator-=(f64 scalar)
スカラ減算代入
Definition GxVectord.inl:2410
GX_FORCE_INLINE void setLength(f64 length)
長さを設定
Definition GxVectord.inl:2664
GX_FORCE_INLINE const f64 & operator[](u32 i) const
const配列
Definition GxVectord.inl:2617
GX_FORCE_INLINE const GxVector4d & divScalar(f64 scalar)
スカラ除算
Definition GxVectord.inl:3136
static GX_FORCE_INLINE const GxVector4d & getMulVector(GxVector4d &dst, const GxVector4d &vector0, const GxVector4d &vector1)
ベクトル乗算を取得
Definition GxVectord.inl:2883
static GX_FORCE_INLINE GxVector4d getLerp(const GxVector4d &vector0, const GxVector4d &vector1, f64 t)
線形補間
Definition GxVectord.inl:3060
GxVector4d(void)
デフォルトコンストラクタ
Definition GxVectord.h:531
GX_FORCE_INLINE const GxVector4d & mulVector(const GxVector4d &vector)
ベクトル乗算
Definition GxVectord.inl:3183
static GX_FORCE_INLINE f64 getDot(const GxVector4d &vector0, const GxVector4d &vector1)
内積を取得
Definition GxVectord.inl:2986
GX_FORCE_INLINE const GxVector4d & divVector(const GxVector4d &vector)
ベクトル除算
Definition GxVectord.inl:3198
static GX_FORCE_INLINE GxVector4d getMaximum(const GxVector4d &vector0, const GxVector4d &vector1)
要素毎に最大値を選択
Definition GxVectord.inl:3028
GX_FORCE_INLINE void setLengthEx(f64 length)
長さを設定(長さ0に対応)
Definition GxVectord.inl:2701
static GX_FORCE_INLINE const GxVector4d & getAddVector(GxVector4d &dst, const GxVector4d &vector0, const GxVector4d &vector1)
ベクトル加算を取得
Definition GxVectord.inl:2849
GX_FORCE_INLINE const GxVector4d & normalize(void)
正規化する
Definition GxVectord.inl:3212
static GX_FORCE_INLINE const GxVector4d & getDivScalar(GxVector4d &dst, const GxVector4d &vector, f64 scalar)
スカラ除算を取得
Definition GxVectord.inl:2830
f64 _w
W値
Definition GxVectord.h:705
GX_FORCE_INLINE b32 isZeroVector(void) const
ゼロベクトルかを取得
Definition GxVectord.inl:2636
GX_FORCE_INLINE GxVector4d getNormalizeEx(void) const
正規化ベクトルを取得(長さ0に対応)
Definition GxVectord.inl:2760
GX_FORCE_INLINE const GxVector4d & subVector(const GxVector4d &vector)
ベクトル減算
Definition GxVectord.inl:3168
static GX_FORCE_INLINE const GxVector4d & getSubVector(GxVector4d &dst, const GxVector4d &vector0, const GxVector4d &vector1)
ベクトル減算を取得
Definition GxVectord.inl:2866
static GX_FORCE_INLINE const GxVector4d & getDivVector(GxVector4d &dst, const GxVector4d &vector0, const GxVector4d &vector1)
ベクトル除算を取得
Definition GxVectord.inl:2900
GX_FORCE_INLINE const GxVector4d & mulScalar(f64 scalar)
スカラ乗算
Definition GxVectord.inl:3121
GX_FORCE_INLINE GxVector4d & operator/=(f64 scalar)
スカラ除算代入
Definition GxVectord.inl:2432
GX_FORCE_INLINE const GxVector4d & addVector(const GxVector4d &vector)
ベクトル加算
Definition GxVectord.inl:3153
GX_FORCE_INLINE GxVector4d & operator=(const GxVector3d &vector)
代入
Definition GxVectord.inl:2371
f64 _x
X値
Definition GxVectord.h:702
GX_FORCE_INLINE const GxVector4d & subScalar(f64 scalar)
スカラ減算
Definition GxVectord.inl:3106
static GX_FORCE_INLINE const GxVector4d & getSubScalar(GxVector4d &dst, const GxVector4d &vector, f64 scalar)
スカラ減算を取得
Definition GxVectord.inl:2796
GX_FORCE_INLINE GxVector4d & operator*=(f64 scalar)
スカラ乗算代入
Definition GxVectord.inl:2421
f64 _z
Z値
Definition GxVectord.h:704
static GX_FORCE_INLINE const GxVector4d & getMulScalar(GxVector4d &dst, const GxVector4d &vector, f64 scalar)
スカラ乗算を取得
Definition GxVectord.inl:2813
GX_FORCE_INLINE const GxVector4d & addScalar(f64 scalar)
スカラ加算
Definition GxVectord.inl:3091
f64 _y
Y値
Definition GxVectord.h:703
GX_FORCE_INLINE f64 getLength(void) const
長さを取得
Definition GxVectord.inl:2645
GX_FORCE_INLINE f64 getLengthSquare(void) const
長さの2乗を取得
Definition GxVectord.inl:2654
32bitブーリアン
Definition GxDefine.h:173