NW4F G3d
Loading...
Searching...
No Matches
g3d_Vector2.h
Go to the documentation of this file.
1#ifndef NW_G3D_MATH_VECTOR2_H_
2#define NW_G3D_MATH_VECTOR2_H_
3
4#include <nw/g3d/g3d_config.h>
5
6namespace nw { namespace g3d { namespace math {
7
8struct Vec2_t
9{
10 enum { DIM = 2, DIM_PS = DIM / 2 };
11
12 union
13 {
14 struct
15 {
16 float x, y;
17 };
18 float a[DIM];
19#if defined( __ghs__ )
20 f32x2 ps[DIM_PS];
21#endif // defined( __ghs__ )
22 };
23};
24
25class Vec2 : public Vec2_t
26{
27public:
28 static Vec2 Make(float x, float y);
29 static Vec2* Cast(float* a);
30 static const Vec2* Cast(const float* a);
31
32 Vec2& Set(float x, float y);
33 Vec2& Set(const float* a);
34 Vec2& Set(const Vec2& v);
35 Vec2& Zero();
36 Vec2& Neg(const Vec2& v);
37 Vec2& Rcp(const Vec2& v);
38
39 Vec2& Add(const Vec2& lhs, const Vec2& rhs);
40 Vec2& Sub(const Vec2& lhs, const Vec2& rhs);
41 Vec2& Mul(const Vec2& lhs, const Vec2& rhs);
42 Vec2& Div(const Vec2& lhs, const Vec2& rhs);
43 Vec2& Mul(const Vec2& lhs, float rhs);
44 Vec2& Div(const Vec2& lhs, float rhs);
45
46 static float Length(const Vec2& v);
47 static float LengthSq(const Vec2& v);
48 static float Distance(const Vec2& lhs, const Vec2& rhs);
49 static float DistanceSq(const Vec2& lhs, const Vec2& rhs);
50 static float Dot(const Vec2& lhs, const Vec2& rhs);
51 float Normalize(const Vec2& v);
52};
53
54} } } // namespace nw::g3d::math
55
56#include "inl/g3d_Vector2-inl.h"
57
58#endif // NW_G3D_MATH_VECTOR2_H_
Definition g3d_Vector2.h:26
Vec2 & Rcp(const Vec2 &v)
Definition g3d_Vector2-inl.h:77
static const Vec2 * Cast(const float *a)
Definition g3d_Vector2-inl.h:18
float Normalize(const Vec2 &v)
Definition g3d_Vector2-inl.h:210
static Vec2 * Cast(float *a)
Definition g3d_Vector2-inl.h:12
Vec2 & Add(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:94
Vec2 & Mul(const Vec2 &lhs, float rhs)
Definition g3d_Vector2-inl.h:145
static float Dot(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:197
Vec2 & Set(const Vec2 &v)
Definition g3d_Vector2-inl.h:43
Vec2 & Neg(const Vec2 &v)
Definition g3d_Vector2-inl.h:63
Vec2 & Set(float x, float y)
Definition g3d_Vector2-inl.h:24
Vec2 & Set(const float *a)
Definition g3d_Vector2-inl.h:32
Vec2 & Mul(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:122
static Vec2 Make(float x, float y)
Definition g3d_Vector2-inl.h:6
static float LengthSq(const Vec2 &v)
Definition g3d_Vector2-inl.h:175
Vec2 & Zero()
Definition g3d_Vector2-inl.h:53
static float DistanceSq(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:189
Vec2 & Div(const Vec2 &lhs, float rhs)
Definition g3d_Vector2-inl.h:159
static float Distance(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:181
Vec2 & Sub(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:108
Vec2 & Div(const Vec2 &lhs, const Vec2 &rhs)
Definition g3d_Vector2-inl.h:136
static float Length(const Vec2 &v)
Definition g3d_Vector2-inl.h:169
Definition g3d_MathCommon.h:6
Definition g3d_GfxManage.cpp:10
Definition g3d_Vector2.h:9
float x
Definition g3d_Vector2.h:16
float a[DIM]
Definition g3d_Vector2.h:18
@ DIM
Definition g3d_Vector2.h:10
@ DIM_PS
Definition g3d_Vector2.h:10
float y
Definition g3d_Vector2.h:16