From 0d286eef9634116828ead278f9534f04ecbb6ecd Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 11 Mar 2017 16:36:28 -0500 Subject: Update a few files... need to get working with linmath. But first switching accounts. --- redist/linmath.h | 6 +++++- redist/lintest.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 redist/lintest.c (limited to 'redist') diff --git a/redist/linmath.h b/redist/linmath.h index 676d182..a58b2bf 100644 --- a/redist/linmath.h +++ b/redist/linmath.h @@ -89,9 +89,13 @@ void quatevenproduct( FLT * q, FLT * qa, FLT * qb ); void quatoddproduct( FLT * outvec3, FLT * qa, FLT * qb ); void quatslerp( FLT * q, const FLT * qa, const FLT * qb, FLT t ); void quatrotatevector( FLT * vec3out, const FLT * quat, const FLT * vec3in ); - void quatfrom2vectors(FLT *q, const FLT *src, const FLT *dest); +//Poses are Position: [x, y, z] Quaternion: [q, x, y, z] +void ApplyPoseToPoint( FLT * pout, const FLT * pin, const FLT * pose ); +void InvertPose( FLT * poseout, const FLT * pose ); + + // Matrix Stuff typedef struct diff --git a/redist/lintest.c b/redist/lintest.c new file mode 100644 index 0000000..0a268ff --- /dev/null +++ b/redist/lintest.c @@ -0,0 +1,41 @@ +#include "linmath.h" +#include + +int main() +{ + + FLT e[3] = { 1,1,3.14 }; + FLT q[4]; + FLT m[16]; + + quatfromeuler( q, e ); + printf( "%f %f %f %f\n\n", PFFOUR( q ) ); + quattomatrix(m,q); + printf( "%f %f %f %f\n", PFFOUR( &m[0] ) ); + printf( "%f %f %f %f\n", PFFOUR( &m[4] ) ); + printf( "%f %f %f %f\n", PFFOUR( &m[8] ) ); + printf( "%f %f %f %f\n\n", PFFOUR( &m[12] ) ); + quatfrommatrix(q,m ); + printf( "%f %f %f %f\n\n", PFFOUR( q ) ); + quattoeuler( e,q ); + printf( "E: %f %f %f\n", e[0], e[1], e[2] ); + + + FLT p[3] = { 0, 0, 1 }; + printf( "%f %f %f\n", PFTHREE( p ) ); + quatrotatevector( p, q, p ); + printf( "%f %f %f\n", PFTHREE( p ) ); + printf( "Flipping rotation\n" ); + q[0] *= -1; //Wow that was easy. + quatrotatevector( p, q, p ); + printf( "%f %f %f\n", PFTHREE( p ) ); + + + //Try setting up a pose. + FLT mypose[7] = { 0, 0, 10, q[0], q[1], q[2], q[3] ); + ApplyPoseToPoint( FLT * pout, const FLT * pin, const FLT * pose ); +void InvertPose( FLT * poseout, const FLT * pose ); + + +} + -- cgit v1.2.3