10#define FLT_EPSILON std::numeric_limits<float>::epsilon()
39 static inline f32 epsilon() {
return 32.0f * FLT_EPSILON; }
40 static inline f32 PI() {
return 3.1415927f; }
46 f32 root = __frsqrte(
x);
47 root = 0.5f * root * (3.0f -
x * (root * root));
58 f32 root = __frsqrte(
x);
59 root = 0.5f * root * (3.0f -
x * (root * root));
67 static inline double epsilon() {
return 32.0f * FLT_EPSILON; }
68 static inline double one() {
return 1.0; }
69 static inline double atan2(
double x,
double y) { return ::atan2(
x,
y); }
70 static inline double asin(
double x) { return ::asin(
x); }
71 static inline double halfPI() {
return 1.5707963267948966; }
91 void set(
double x_,
double y_,
double z_) {
121 *((
s32*)
this) = *((
s32*)&b);
139 psq_l a_x, 0(vec_a), 0, 0
141 psq_st a_x, 0(vec_b), 0, 0
154 f32 root = __frsqrte(mag);
155 return 0.5f * root * (3.0f - mag * (root * root));
161 __REGISTER
f32 a_x_y;
162 __REGISTER
f32 b_x_y;
169 psq_l a_x_y, 0(
a), 0, 0
170 psq_l b_x_y, 0(b), 0, 0
171 ps_mul x_y, a_x_y, b_x_y
172 psq_st x_y, 0(dst), 0, 0
174 dst[2] =
a[2] * b[2];
196 operator const Vec*()
const {
return (
Vec*)&
x; }
212 void set(U x_, U y_, U z_) {
270 return inv_norm * sq;
274 f32 sq = other.squared();
285 return VECMag((
Vec*)
this);
289#if PLATFORM_GCN && defined(__MWERKS__)
292 __REGISTER
f32* dst = &
x;
296 psq_l x_y, 0(dst), 0, 0
297 psq_l
z, 8(dst), 1, 0
298 ps_muls0 x_y, x_y, sc
299 psq_st x_y, 0(dst), 0, 0
301 psq_st zres, 8(dst), 1, 0
311#if PLATFORM_GCN && defined(__MWERKS__)
312 __REGISTER
const f32*
src = &other.
x;
315 __REGISTER
f32* dst = &
x;
319 psq_l x_y, 0(
src), 0, 0
320 psq_l
z, 8(
src), 1, 0
321 ps_muls0 x_y, x_y, sc
322 psq_st x_y, 0(dst), 0, 0
324 psq_st zres, 8(dst), 1, 0
339 __REGISTER
f32* rdst = &dst->
x;
340 const __REGISTER
f32*
src = &
x;
345 psq_l x_y, 0(
src), 0, 0
347 psq_st x_y, 0(rdst), 0, 0
356 negateInternal(
this);
381 scale(inv_norm * len);
382 return inv_norm * sq;
386 f32 sq = other.squared();
392 scale(inv_norm * len, other);
393 return inv_norm * sq;
402 f32 fVar5 = param_5 * param_5;
403 f32 fVar6 = fVar5 * param_5;
404 f32 fVar8 = 1.0f + (2.0f * fVar6 - 3.0f * fVar5);
405 f32 fVar9 = -2.0f * fVar6 + 3.0f * fVar5;
406 f32 fVar7 = param_5 + (fVar6 - 2.0f * fVar5);
407 f32 fVar4 = fVar6 - fVar5;
408 x = fVar8 * param_1.
x + fVar9 * param_4.
x + fVar7 * param_2.
x + fVar4 * param_3.
x;
409 y = fVar8 * param_1.
y + fVar9 * param_4.
y + fVar7 * param_2.
y + fVar4 * param_3.
y;
410 z = fVar8 * param_1.
z + fVar9 * param_4.
z + fVar7 * param_2.
z + fVar4 * param_3.
z;
419 template <
typename U>
424 template <
typename U>
430 template <
typename U>
457 if (this->
x == other.
x && this->y == other.
y) {
464 return (
x >= other.
x) && (
y >= other.
y) ?
true :
false;
468 return x * other.
x +
y * other.
y;
518 if (this->isValid()) {
523 this->
i.setMin(box.
i);
524 this->
i.setMin(box.
f);
525 this->
f.setMax(box.
i);
526 this->
f.setMax(box.
f);
static int min(int a, int b)
Definition JHIComm.cpp:155
void JMAVECScaleAdd(__REGISTER const Vec *vec1, __REGISTER const Vec *vec2, __REGISTER Vec *dst, __REGISTER f32 scale)
Definition JMath.cpp:74
asm void PSVECCrossProduct(const __REGISTER Vec *a, const __REGISTER Vec *b, __REGISTER Vec *axb)
Definition vec.c:206
const void * src
Definition __os.h:116
double x double x
Definition e_atan2.c:58
static const static double double zero
Definition e_atan2.c:50
double x double y
Definition e_atan2.c:58
double y1
Definition e_pow.c:114
double v
Definition e_pow.c:114
signed short int s16
Definition types.h:9
float f32
Definition types.h:25
signed long s32
Definition types.h:11
Definition JGeometry.h:13
float fsqrt_step(float mag)
Definition JGeometry.h:152
void mulInternal(__REGISTER const f32 *a, __REGISTER const f32 *b, __REGISTER float *dst)
Definition JGeometry.h:159
void setTVec3f(const __REGISTER f32 *vec_a, __REGISTER f32 *vec_b)
Definition JGeometry.h:133
void C_VECSubtract(__REGISTER const Vec *a, __REGISTER const Vec *b, __REGISTER Vec *ab)
Definition JMath.h:217
f32 C_VECDotProduct(__REGISTER const Vec *a, __REGISTER const Vec *b)
Definition JMath.h:254
f32 C_VECSquareMag(__REGISTER const Vec *v)
Definition JMath.h:237
void C_VECAdd(__REGISTER const Vec *a, __REGISTER const Vec *b, __REGISTER Vec *ab)
Definition JMath.h:196
Definition JGeometry.h:533
void set(const TVec2< f32 > &i, const TVec2< f32 > &f)
Definition JGeometry.h:542
void set(const TBox< TVec2< T > > &other)
Definition JGeometry.h:541
TBox2(f32 x0, f32 y0, f32 x1, f32 y1)
Definition JGeometry.h:539
void set(f32 x0, f32 y0, f32 x1, f32 y1)
Definition JGeometry.h:543
TBox2()
Definition JGeometry.h:534
TBox2(const TVec2< f32 > &_i, const TVec2< f32 > &_f)
Definition JGeometry.h:535
void absolute()
Definition JGeometry.h:517
TVec2< f32 > f
Definition JGeometry.h:529
void addPos(const TVec2< f32 > &pos)
Definition JGeometry.h:506
bool intersect(const TBox< TVec2< f32 > > &other)
Definition JGeometry.h:511
f32 getHeight() const
Definition JGeometry.h:498
bool isValid() const
Definition JGeometry.h:500
f32 getWidth() const
Definition JGeometry.h:497
void addPos(f32 x, f32 y)
Definition JGeometry.h:502
Definition JGeometry.h:488
TBox(const TBox &other)
Definition JGeometry.h:490
TBox()
Definition JGeometry.h:489
T i
Definition JGeometry.h:492
T f
Definition JGeometry.h:492
static double one()
Definition JGeometry.h:68
static double halfPI()
Definition JGeometry.h:71
static double epsilon()
Definition JGeometry.h:67
static double atan2(double x, double y)
Definition JGeometry.h:69
static double asin(double x)
Definition JGeometry.h:70
static f32 inv_sqrt(f32 x)
Definition JGeometry.h:41
static f32 clamp(f32 v, f32 min, f32 max)
Definition JGeometry.h:30
static f32 PI()
Definition JGeometry.h:40
static f32 epsilon()
Definition JGeometry.h:39
static f32 sqrt(f32 x)
Definition JGeometry.h:52
Definition JGeometry.h:16
static T clamp(T v, T min, T max)
Definition JGeometry.h:17
Definition JGeometry.h:415
void set(const U x, const U y)
Definition JGeometry.h:425
bool isAbove(const TVec2< T > &other) const
Definition JGeometry.h:463
void setMax(const TVec2< f32 > &max)
Definition JGeometry.h:443
void add(const TVec2< T > &other)
Definition JGeometry.h:450
void set(T v)
Definition JGeometry.h:422
f32 squared() const
Definition JGeometry.h:471
f32 dot(const TVec2< T > &other) const
Definition JGeometry.h:467
bool operator==(const TVec2< T > &other) const
Definition JGeometry.h:479
TVec2(const U x, const U y)
Definition JGeometry.h:420
TVec2()
Definition JGeometry.h:416
void setMin(const TVec2< f32 > &min)
Definition JGeometry.h:436
TVec2(T v)
Definition JGeometry.h:417
void set(const TVec2< U > &other)
Definition JGeometry.h:431
T x
Definition JGeometry.h:483
T y
Definition JGeometry.h:484
bool equals(const TVec2< T > &other) const
Definition JGeometry.h:455
f32 length() const
Definition JGeometry.h:475
void scale(double b)
Definition JGeometry.h:102
void set(double x_, double y_, double z_)
Definition JGeometry.h:91
double x
Definition JGeometry.h:89
TVec3< double > & operator*=(double b)
Definition JGeometry.h:97
void mul(const TVec3< f32 > &a)
Definition JGeometry.h:228
f32 squared() const
Definition JGeometry.h:259
void cross(const TVec3< f32 > &a, const TVec3< f32 > &b)
Definition JGeometry.h:371
TVec3< f32 > & operator+=(const TVec3< f32 > &b)
Definition JGeometry.h:242
void mul(const TVec3< f32 > &a, const TVec3< f32 > &b)
Definition JGeometry.h:224
TVec3(const TVec3< f32 > &i_vec)
Definition JGeometry.h:184
f32 normalize(const TVec3< f32 > &other)
Definition JGeometry.h:273
TVec3()
Definition JGeometry.h:193
void scale(__REGISTER f32 sc, const TVec3< f32 > &other)
Definition JGeometry.h:310
f32 length() const
Definition JGeometry.h:284
TVec3< f32 > operator+(const TVec3< f32 > &b) const
Definition JGeometry.h:247
void negate()
Definition JGeometry.h:355
TVec3(const Vec &i_vec)
Definition JGeometry.h:180
TVec3(U x, U y, U z)
Definition JGeometry.h:189
bool isZero() const
Definition JGeometry.h:367
f32 setLength(f32 len)
Definition JGeometry.h:375
f32 setLength(const TVec3< f32 > &other, f32 len)
Definition JGeometry.h:385
TVec3< f32 > & operator=(const Vec &b)
Definition JGeometry.h:232
f32 normalize()
Definition JGeometry.h:263
void sub(const TVec3< f32 > &a, const TVec3< f32 > &b)
Definition JGeometry.h:363
void scaleAdd(__REGISTER f32 sc, const TVec3< f32 > &a, const TVec3< f32 > &b)
Definition JGeometry.h:333
void sub(const TVec3< f32 > &b)
Definition JGeometry.h:359
void zero()
Definition JGeometry.h:222
void scale(__REGISTER f32 sc)
Definition JGeometry.h:288
void set(const TVec3< U > &other)
Definition JGeometry.h:199
TVec3< f32 > & operator=(const TVec3< f32 > &b)
Definition JGeometry.h:237
void negateInternal(TVec3< f32 > *dst)
Definition JGeometry.h:337
void cubic(const TVec3< f32 > ¶m_1, const TVec3< f32 > ¶m_2, const TVec3< f32 > ¶m_3, const TVec3< f32 > ¶m_4, f32 param_5)
Definition JGeometry.h:400
void set(U x_, U y_, U z_)
Definition JGeometry.h:212
void set(const Vec &other)
Definition JGeometry.h:205
f32 dot(const TVec3< f32 > &other) const
Definition JGeometry.h:396
void add(const TVec3< f32 > &b)
Definition JGeometry.h:218
TVec3()
Definition JGeometry.h:113
s16 x
Definition JGeometry.h:111
void set(s16 x_, s16 y_, s16 z_)
Definition JGeometry.h:126
TVec3 & operator=(const TVec3 &b)
Definition JGeometry.h:119
TVec3(s16 x, s16 y, s16 z)
Definition JGeometry.h:115
Definition JGeometry.h:75
T x
Definition JGeometry.h:76
void set(const TVec3 &other)
Definition JGeometry.h:80
T z
Definition JGeometry.h:78
T y
Definition JGeometry.h:77