aboutsummaryrefslogtreecommitdiff
path: root/redist/linmath.h
diff options
context:
space:
mode:
Diffstat (limited to 'redist/linmath.h')
-rw-r--r--redist/linmath.h71
1 files changed, 33 insertions, 38 deletions
diff --git a/redist/linmath.h b/redist/linmath.h
index cacb1c6..1a73a06 100644
--- a/redist/linmath.h
+++ b/redist/linmath.h
@@ -1,18 +1,18 @@
-//Copyright 2013,2016 <>< C. N. Lohr. This file licensed under the terms of the MIT/x11 license.
+// Copyright 2013,2016 <>< C. N. Lohr. This file licensed under the terms of the MIT/x11 license.
#ifndef _LINMATH_H
#define _LINMATH_H
-//Yes, I know it's kind of arbitrary.
+// Yes, I know it's kind of arbitrary.
#define DEFAULT_EPSILON 0.001
-//For printf
+// For printf
#define PFTHREE(x) (x)[0], (x)[1], (x)[2]
#define PFFOUR(x) (x)[0], (x)[1], (x)[2], (x)[3]
#define LINMATHPI ((FLT)3.141592653589)
-//uncomment the following line to use double precision instead of single precision.
+// uncomment the following line to use double precision instead of single precision.
//#define USE_DOUBLE
#ifdef USE_DOUBLE
@@ -20,11 +20,11 @@
#define FLT double
#define FLT_SQRT sqrt
#define FLT_TAN tan
-#define FLT_SIN sin
-#define FLT_COS cos
-#define FLT_ACOS acos
-#define FLT_ASIN asin
-#define FLT_ATAN2 atan2
+#define FLT_SIN sin
+#define FLT_COS cos
+#define FLT_ACOS acos
+#define FLT_ASIN asin
+#define FLT_ATAN2 atan2
#define FLT_FABS__ fabs
#else
@@ -32,24 +32,24 @@
#define FLT float
#define FLT_SQRT sqrtf
#define FLT_TAN tanf
-#define FLT_SIN sinf
-#define FLT_COS cosf
-#define FLT_ACOS acosf
-#define FLT_ASIN asinf
-#define FLT_ATAN2 atan2f
+#define FLT_SIN sinf
+#define FLT_COS cosf
+#define FLT_ACOS acosf
+#define FLT_ASIN asinf
+#define FLT_ATAN2 atan2f
#define FLT_FABS__ fabsf
#endif
#ifdef TCC
-#define FLT_FABS(x) (((x)<0)?(-(x)):(x))
+#define FLT_FABS(x) (((x) < 0) ? (-(x)) : (x))
#else
#define FLT_FABS FLT_FABS__
#endif
typedef FLT LinmathQuat[4]; // This is the [wxyz] quaternion, in wxyz format.
typedef FLT LinmathPoint3d[3];
-typedef FLT linmathVec3d[3];
+typedef FLT LinmathVec3d[3];
typedef struct LinmathPose {
LinmathPoint3d Pos;
@@ -59,33 +59,33 @@ typedef struct LinmathPose {
extern LinmathQuat LinmathQuat_Identity;
extern LinmathPose LinmathPose_Identity;
-//NOTE: Inputs may never be output with cross product.
-void cross3d( FLT * out, const FLT * a, const FLT * b );
+// NOTE: Inputs may never be output with cross product.
+void cross3d(FLT *out, const FLT *a, const FLT *b);
-void sub3d( FLT * out, const FLT * a, const FLT * b );
+void sub3d(FLT *out, const FLT *a, const FLT *b);
-void add3d( FLT * out, const FLT * a, const FLT * b );
+void add3d(FLT *out, const FLT *a, const FLT *b);
-void scale3d( FLT * out, const FLT * a, FLT scalar );
+void scale3d(FLT *out, const FLT *a, FLT scalar);
-void normalize3d( FLT * out, const FLT * in );
+void normalize3d(FLT *out, const FLT *in);
-FLT dot3d( const FLT * a, const FLT * b );
+FLT dot3d(const FLT *a, const FLT *b);
-//Returns 0 if equal. If either argument is null, 0 will ALWAYS be returned.
-int compare3d( const FLT * a, const FLT * b, FLT epsilon );
+// Returns 0 if equal. If either argument is null, 0 will ALWAYS be returned.
+int compare3d(const FLT *a, const FLT *b, FLT epsilon);
-void copy3d( FLT * out, const FLT * in );
+void copy3d(FLT *out, const FLT *in);
-FLT magnitude3d(const FLT * a );
+FLT magnitude3d(const FLT *a);
-FLT anglebetween3d( FLT * a, FLT * b );
+FLT anglebetween3d(FLT *a, FLT *b);
void rotatearoundaxis(FLT *outvec3, FLT *invec3, FLT *axis, FLT angle);
void angleaxisfrom2vect(FLT *angle, FLT *axis, FLT *src, FLT *dest);
void axisanglefromquat(FLT *angle, FLT *axis, LinmathQuat quat);
-//Quaternion things...
+// Quaternion things...
typedef FLT LinmathEulerAngle[3];
@@ -126,10 +126,10 @@ void ApplyPoseToPose(LinmathPose *pout, const LinmathPose *lhs_pose, const Linma
// by definition.
void InvertPose(LinmathPose *poseout, const LinmathPose *pose_in);
+void PoseToMatrix(FLT *mat44, const LinmathPose *pose_in);
// Matrix Stuff
-typedef struct
-{
+typedef struct {
FLT val[3][3]; // row, column
} Matrix3x3;
@@ -137,12 +137,7 @@ void rotate_vec(FLT *out, const FLT *in, Matrix3x3 rot);
void rotation_between_vecs_to_m3(Matrix3x3 *m, const FLT v1[3], const FLT v2[3]);
Matrix3x3 inverseM33(const Matrix3x3 mat);
-
-void matrix44copy(FLT * mout, const FLT * minm );
-void matrix44transpose(FLT * mout, const FLT * minm );
-
+void matrix44copy(FLT *mout, const FLT *minm);
+void matrix44transpose(FLT *mout, const FLT *minm);
#endif
-
-
-