NW4F G3d
Loading...
Searching...
No Matches
g3d_Vector3.h
Go to the documentation of this file.
1#ifndef NW_G3D_MATH_VECTOR3_H_
2#define NW_G3D_MATH_VECTOR3_H_
3
4#include <nw/g3d/g3d_config.h>
5
6namespace nw { namespace g3d { namespace math {
7
8class Mtx34;
9class Mtx44;
10class Quat;
11
12struct Vec3_t
13{
14 enum { DIM = 3, DIM_PS = DIM / 2 };
15
16 union
17 {
18 struct
19 {
20 float x, y, z;
21 };
22 float a[DIM];
23#if defined( __ghs__ )
24 f32x2 ps[DIM_PS];
25#endif // defined( __ghs__ )
26 };
27};
28
29class Vec3 : public Vec3_t
30{
31public:
32 static Vec3 Make(float x, float y, float z);
33 static Vec3* Cast(float* a);
34 static const Vec3* Cast(const float* a);
35
36 Vec3& Set(float x, float y, float z);
37 Vec3& Set(const float* a);
38 Vec3& Set(const Vec3& v);
39 Vec3& Zero();
40 Vec3& Neg(const Vec3& v);
41 Vec3& Rcp(const Vec3& v);
42
43 Vec3& Add(const Vec3& lhs, const Vec3& rhs);
44 Vec3& Sub(const Vec3& lhs, const Vec3& rhs);
45 Vec3& Mul(const Vec3& lhs, const Vec3& rhs);
46 Vec3& Div(const Vec3& lhs, const Vec3& rhs);
47 Vec3& Mul(const Vec3& lhs, float rhs);
48 Vec3& Div(const Vec3& lhs, float rhs);
49 Vec3& Mad(const Vec3& lhsMul, float rhsMul, const Vec3& add);
50 Vec3& Mul(const Mtx34& lhs, const Vec3& rhs);
51
52 static float Length(const Vec3& v);
53 static float LengthSq(const Vec3& v);
54 static float Distance(const Vec3& lhs, const Vec3& rhs);
55 static float DistanceSq(const Vec3& lhs, const Vec3& rhs);
56 static float Dot(const Vec3& lhs, const Vec3& rhs);
57 Vec3& Cross(const Vec3& lhs, const Vec3& rhs);
58 float Normalize(const Vec3& v);
59
60 Vec3& Transform(const Mtx34& m, const Vec3& v);
61 Vec3& Rotate(const Mtx34& m, const Vec3& v);
62 Vec3& Rotate(const Quat& q, const Vec3& v);
63 Vec3& Project(const Mtx44& m, const Vec3& v);
64};
65
66} } } // namespace nw::g3d::math
67
68#include "inl/g3d_Vector3-inl.h"
69
70#endif // NW_G3D_MATH_VECTOR3_H_
Definition g3d_Matrix34.h:34
Definition g3d_Matrix44.h:37
Definition g3d_Quaternion.h:28
Definition g3d_Vector3.h:30
Vec3 & Mad(const Vec3 &lhsMul, float rhsMul, const Vec3 &add)
Definition g3d_Vector3-inl.h:169
Vec3 & Add(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:100
Vec3 & Set(const Vec3 &v)
Definition g3d_Vector3-inl.h:47
Vec3 & Set(float x, float y, float z)
Definition g3d_Vector3-inl.h:27
static float DistanceSq(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:255
Vec3 & Div(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:145
static Vec3 * Cast(float *a)
Definition g3d_Vector3-inl.h:15
Vec3 & Rcp(const Vec3 &v)
Definition g3d_Vector3-inl.h:82
Vec3 & Cross(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:276
Vec3 & Rotate(const Mtx34 &m, const Vec3 &v)
Definition g3d_Vector3-inl.h:307
static float Length(const Vec3 &v)
Definition g3d_Vector3-inl.h:235
Vec3 & Mul(const Mtx34 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:192
Vec3 & Project(const Mtx44 &m, const Vec3 &v)
Definition g3d_Vector3-inl.h:366
float Normalize(const Vec3 &v)
Definition g3d_Vector3-inl.h:286
Vec3 & Mul(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:130
Vec3 & Sub(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:115
Vec3 & Set(const float *a)
Definition g3d_Vector3-inl.h:36
static Vec3 Make(float x, float y, float z)
Definition g3d_Vector3-inl.h:9
Vec3 & Div(const Vec3 &lhs, float rhs)
Definition g3d_Vector3-inl.h:184
static float Dot(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:263
Vec3 & Mul(const Vec3 &lhs, float rhs)
Definition g3d_Vector3-inl.h:154
Vec3 & Zero()
Definition g3d_Vector3-inl.h:57
static const Vec3 * Cast(const float *a)
Definition g3d_Vector3-inl.h:21
Vec3 & Transform(const Mtx34 &m, const Vec3 &v)
Definition g3d_Vector3-inl.h:301
static float LengthSq(const Vec3 &v)
Definition g3d_Vector3-inl.h:241
Vec3 & Neg(const Vec3 &v)
Definition g3d_Vector3-inl.h:67
Vec3 & Rotate(const Quat &q, const Vec3 &v)
Definition g3d_Vector3-inl.h:351
static float Distance(const Vec3 &lhs, const Vec3 &rhs)
Definition g3d_Vector3-inl.h:247
Definition g3d_MathCommon.h:6
Definition g3d_GfxManage.cpp:10
Definition g3d_Vector3.h:13
float x
Definition g3d_Vector3.h:20
float y
Definition g3d_Vector3.h:20
float z
Definition g3d_Vector3.h:20
float a[DIM]
Definition g3d_Vector3.h:22
@ DIM
Definition g3d_Vector3.h:14
@ DIM_PS
Definition g3d_Vector3.h:14