Skip to content

Instantly share code, notes, and snippets.

@powerc9000
Created March 15, 2016 01:34
Show Gist options
  • Save powerc9000/6d159a735f2a59b88398 to your computer and use it in GitHub Desktop.
Save powerc9000/6d159a735f2a59b88398 to your computer and use it in GitHub Desktop.
Some vectors
struct vector3D {
float x;
float y;
float z;
}
//now we can make some vector functions
vector3D add(vector3D left, vector3D right){
vector3D result = {};
result.x = left.x + right.x;
result.y = left.y + right.y;
result.z = left.z + right.z;
return result;
}
vector3D mul(vector3D vector, float scalar){
vector3D result = {};
result.x = vector.x * scalar;
result.y = vector.y * scalar;
result.z = vector.z * scalar;
return result;
}
float dot(vector3D left, vector3D right){
float result = (left.x * right.x) + (left.y * right.y) + (left.z * right.z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment