Skip to content

Instantly share code, notes, and snippets.

@kenpower
Last active March 23, 2017 11:16
Show Gist options
  • Save kenpower/4032551 to your computer and use it in GitHub Desktop.
Save kenpower/4032551 to your computer and use it in GitHub Desktop.
Using Assimp aiVector3D and aiMatrix3x3
/*+++++++++++++++++++++++++++++++++++++++++
Some sample code showing how to do basic vector operations with assimp
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// create a 3d Vector
aiVector3D a(1.0f,2.0f,3.0f);
aiVector3D b=a; //copy vector to another
b.x=0.f; //assign value to x component of b
//out put a vector
std::cout << a.x << "," << a.y << "," << a.z << "\n";
float d=a*b;//dotproduct (a & b are vectors)
std::cout << d << "\n";
aiVector3D c;
c=a*5.0f; //scalar product
c*=5.0f; //scalar product
a=b^c;// cross product
std::cout << a.x << "," << a.y << "," << a.z << "\n";
a.Normalize(); //make length equal one
std::cout << a.x << "," << a.y << "," << a.z << "\n";
float l=c.Length();
a=b+c; //vector addition
a.Set(1,2,3); //set the elements
aiMatrix3x3 m; //creat a 3x3 matrix
aiMatrix4x4 n(m); //create a 4x4 matrix
const float PI=3.141f;
float angle=PI/4;//angle in radians
aiMatrix3x3.Rotation(angle,a,m); //create rotation vector of angle about axis a
//m contains the new matrix
b*=m; //apply transformation m to vector b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment