Skip to content
Permalink
Browse files

Added sgVec?<Op>f conveniency functions

  • Loading branch information...
darkuranium committed Nov 23, 2014
1 parent 182f458 commit f7a650f9744041fc2f09487301f06692bd3115d6
Showing with 66 additions and 0 deletions.
  1. +15 −0 include/siege/util/vector.h
  2. +51 −0 src/siege/util/vector.c
@@ -91,6 +91,11 @@ SGVec2 SG_CALL sgVec2Sub(SGVec2 a, SGVec2 b);
SGVec2 SG_CALL sgVec2Mul(SGVec2 a, SGVec2 b);
SGVec2 SG_CALL sgVec2Div(SGVec2 a, SGVec2 b);

SGVec2 SG_CALL sgVec2Addf(SGVec2 a, float f);
SGVec2 SG_CALL sgVec2Subf(SGVec2 a, float f);
SGVec2 SG_CALL sgVec2Mulf(SGVec2 a, float f);
SGVec2 SG_CALL sgVec2Divf(SGVec2 a, float f);

SGVec2 SG_CALL sgVec2QMul2(SGVec2 a, SGVec2 b);

float SG_CALL sgVec2Distance(SGVec2 a, SGVec2 b);
@@ -140,6 +145,11 @@ SGVec3 SG_CALL sgVec3Sub(SGVec3 a, SGVec3 b);
SGVec3 SG_CALL sgVec3Mul(SGVec3 a, SGVec3 b);
SGVec3 SG_CALL sgVec3Div(SGVec3 a, SGVec3 b);

SGVec3 SG_CALL sgVec3Addf(SGVec3 a, float f);
SGVec3 SG_CALL sgVec3Subf(SGVec3 a, float f);
SGVec3 SG_CALL sgVec3Mulf(SGVec3 a, float f);
SGVec3 SG_CALL sgVec3Divf(SGVec3 a, float f);

float SG_CALL sgVec3Distance(SGVec3 a, SGVec3 b);
float SG_CALL sgVec3Distance2(SGVec3 a, SGVec3 b);

@@ -180,6 +190,11 @@ SGVec4 SG_CALL sgVec4Sub(SGVec4 a, SGVec4 b);
SGVec4 SG_CALL sgVec4Mul(SGVec4 a, SGVec4 b);
SGVec4 SG_CALL sgVec4Div(SGVec4 a, SGVec4 b);

SGVec4 SG_CALL sgVec4Addf(SGVec4 a, float f);
SGVec4 SG_CALL sgVec4Subf(SGVec4 a, float f);
SGVec4 SG_CALL sgVec4Mulf(SGVec4 a, float f);
SGVec4 SG_CALL sgVec4Divf(SGVec4 a, float f);

SGVec4 SG_CALL sgVec4QMul4(SGVec4 a, SGVec4 b);

float SG_CALL sgVec4Distance(SGVec4 a, SGVec4 b);
@@ -108,6 +108,23 @@ SGVec2 SG_CALL sgVec2Div(SGVec2 a, SGVec2 b)
return sgVec2f(a.x / b.x, a.y / b.y);
}

SGVec2 SG_CALL sgVec2Addf(SGVec2 a, float f)
{
return sgVec2Add(a, sgVec2f(f, f));
}
SGVec2 SG_CALL sgVec2Subf(SGVec2 a, float f)
{
return sgVec2Sub(a, sgVec2f(f, f));
}
SGVec2 SG_CALL sgVec2Mulf(SGVec2 a, float f)
{
return sgVec2Mul(a, sgVec2f(f, f));
}
SGVec2 SG_CALL sgVec2Divf(SGVec2 a, float f)
{
return sgVec2Div(a, sgVec2f(f, f));
}

float SG_CALL sgVec2Distance(SGVec2 a, SGVec2 b)
{
return sgVec2Length(sgVec2Sub(a, b));
@@ -263,6 +280,23 @@ SGVec3 SG_CALL sgVec3Div(SGVec3 a, SGVec3 b)
return sgVec3f(a.x / b.x, a.y / b.y, a.z / b.z);
}

SGVec3 SG_CALL sgVec3Addf(SGVec3 a, float f)
{
return sgVec3Add(a, sgVec3f(f, f, f));
}
SGVec3 SG_CALL sgVec3Subf(SGVec3 a, float f)
{
return sgVec3Sub(a, sgVec3f(f, f, f));
}
SGVec3 SG_CALL sgVec3Mulf(SGVec3 a, float f)
{
return sgVec3Mul(a, sgVec3f(f, f, f));
}
SGVec3 SG_CALL sgVec3Divf(SGVec3 a, float f)
{
return sgVec3Div(a, sgVec3f(f, f, f));
}

float SG_CALL sgVec3Distance(SGVec3 a, SGVec3 b)
{
return sgVec3Length(sgVec3Sub(a, b));
@@ -389,6 +423,23 @@ SGVec4 SG_CALL sgVec4Div(SGVec4 a, SGVec4 b)
return sgVec4f(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
}

SGVec4 SG_CALL sgVec4Addf(SGVec4 a, float f)
{
return sgVec4Add(a, sgVec4f(f, f, f, f));
}
SGVec4 SG_CALL sgVec4Subf(SGVec4 a, float f)
{
return sgVec4Sub(a, sgVec4f(f, f, f, f));
}
SGVec4 SG_CALL sgVec4Mulf(SGVec4 a, float f)
{
return sgVec4Mul(a, sgVec4f(f, f, f, f));
}
SGVec4 SG_CALL sgVec4Divf(SGVec4 a, float f)
{
return sgVec4Div(a, sgVec4f(f, f, f, f));
}

SGVec4 SG_CALL sgVec4QMul4(SGVec4 a, SGVec4 b)
{
// (ax + ay I + az J + aw K) * (bx + by I + bz J + bw K)

0 comments on commit f7a650f

Please sign in to comment.
You can’t perform that action at this time.