Created
March 15, 2016 01:34
-
-
Save powerc9000/6d159a735f2a59b88398 to your computer and use it in GitHub Desktop.
Some vectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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