Skip to content

Commit 1767b7a

Browse files
authored
Merge pull request #1164 from z64555/cleanup/doxy_vecmat
Doxy vm_vector_2_matrix functions.
2 parents 340b8d3 + db3e2ae commit 1767b7a

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

code/math/vecmat.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,15 @@ matrix *vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a)
780780
return t;
781781
}
782782

783-
//generate the vectors for the vm_vector_2_matrix() an vm_vector_2_matrix_norm() functions so we can avoid goto
783+
/**
784+
* @brief Generates a matrix from a normalized fvec.
785+
*
786+
* @param[in,out] matrix The matrix to generate
787+
*
788+
* @details The matrix's fvec is used to generate the uvec and rvec
789+
*
790+
* @sa vm_vector_2_matrix(), vm_vector_2_matrix_norm()
791+
*/
784792
void vm_vector_2_matrix_gen_vectors(matrix *m)
785793
{
786794
vec3d *xvec=&m->vec.rvec;
@@ -806,11 +814,6 @@ void vm_vector_2_matrix_gen_vectors(matrix *m)
806814
}
807815
}
808816

809-
//computes a matrix from one or more vectors. The forward vector is required,
810-
//with the other two being optional. If both up & right vectors are passed,
811-
//the up vector is used. If only the forward vector is passed, a bank of
812-
//zero is assumed
813-
//returns ptr to matrix
814817
matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
815818
{
816819
vec3d fvec_norm;
@@ -832,7 +835,6 @@ matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, cons
832835
return vm_vector_2_matrix_norm(m, fvec, uvec, rvec);
833836
}
834837

835-
//quicker version of vm_vector_2_matrix() that takes normalized vectors
836838
matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
837839
{
838840
matrix temp = *m;
@@ -874,7 +876,8 @@ matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec,
874876
temp.vec.fvec = *fvec;
875877

876878
vm_vector_2_matrix_gen_vectors(&temp);
877-
} else {
879+
}
880+
else {
878881
//normalize new perpendicular vector
879882
vm_vec_normalize(xvec);
880883

code/math/vecmat.h

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,39 @@ matrix *vm_angle_2_matrix(matrix *m, float a, int angle_index);
237237
//computes a matrix from a forward vector and an angle
238238
matrix *vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a);
239239

240-
//computes a matrix from one or more vectors. The forward vector is required,
241-
//with the other two being optional. If both up & right vectors are passed,
242-
//the up vector is used. If only the forward vector is passed, a bank of
243-
//zero is assumed
244-
//returns ptr to matrix
240+
/**
241+
* @brief Generates a matrix from one or more vectors
242+
*
243+
* @param[out] matrix The generated matrix. Does not need to be an Identity matrix
244+
* @param[in] fvec Vector referencing the forward direction
245+
* @param[in] uvec Vector referencing the up direction (Optional)
246+
* @param[in] rvec Vector referencing the right-hand direction (Optional)
247+
*
248+
* @returns Pointer to the generated matrix
249+
*
250+
* @note If all three vectors are given, rvec is ignored.
251+
* @note If uvec was bogus (either being in the same direction of fvec or -fvec) then only fvec is used
252+
*
253+
* @sa vm_vector_2_matrix_norm
254+
*/
245255
matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec);
246256

247-
//this version of vector_2_matrix requires that the vectors be more-or-less
248-
//normalized and close to perpendicular
257+
258+
/**
259+
* @brief Generates a matrix from one or more normalized vectors
260+
*
261+
* @param[out] matrix The generated matrix. Does not need to be an Identity matrix
262+
* @param[in] fvec Normalized Vector referencing the forward direction
263+
* @param[in] uvec Normalized Vector referencing the up direction (Optional)
264+
* @param[in] rvec Normalized Vector referencing the right-hand direction (Optional)
265+
*
266+
* @returns Pointer to the generated matrix
267+
*
268+
* @note If all three vectors are given, rvec is ignored.
269+
* @note If uvec was bogus (either being in the same direction of fvec or -fvec) then only fvec is used
270+
*
271+
* @sa vm_vector_2_matrix
272+
*/
249273
matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec = NULL, const vec3d *rvec = NULL);
250274

251275
//rotates a vector through a matrix. returns ptr to dest vector

0 commit comments

Comments
 (0)