Add vector_sub_vector and vector_dot to basics
This commit is contained in:
parent
cee4113f6a
commit
0c050734c7
2 changed files with 22 additions and 0 deletions
19
src/basics.c
19
src/basics.c
|
@ -52,6 +52,18 @@ vector_mult_vector(Vector3 v, Vector3 f)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* vector_sub_vector --
|
||||
*
|
||||
* Subtract s from m. Return a new vector.
|
||||
*/
|
||||
Vector3
|
||||
vector_sub_vector(Vector3 m, Vector3 s)
|
||||
{
|
||||
return vector_init(m.x - s.x, m.y - s.y, m.z - s.z);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* vector_length2 --
|
||||
*
|
||||
|
@ -76,6 +88,13 @@ vector_length(Vector3 v)
|
|||
}
|
||||
|
||||
|
||||
float
|
||||
vector_dot(Vector3 v, Vector3 f)
|
||||
{
|
||||
return (v.x * f.x) + (v.y * f.x) + (v.z * f.z);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* vector_normalize --
|
||||
*
|
||||
|
|
|
@ -23,8 +23,11 @@ extern const Vector3 ZeroVector3;
|
|||
Vector3 vector_init(float x, float y, float z);
|
||||
Vector3 vector_mult_scalar(Vector3 v, float f);
|
||||
Vector3 vector_mult_vector(Vector3 v, Vector3 f);
|
||||
Vector3 vector_sub_vector(Vector3 m, Vector3 s);
|
||||
float vector_length2(Vector3 v);
|
||||
float vector_length(Vector3 v);
|
||||
float vector_dot(Vector3 v, Vector3 f);
|
||||
|
||||
Vector3 vector_normalize(Vector3 v);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue