Skip to content

Commit bdccb25

Browse files
authored
Merge pull request #3083 from Baezon/comment-delta-ang
Improve comment on vm_vec_delta_ang
2 parents 6a049cc + fc7e1f0 commit bdccb25

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

code/math/vecmat.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -540,46 +540,48 @@ vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1,const vec3d *p2
540540

541541
//computes the delta angle between two vectors.
542542
//vectors need not be normalized. if they are, call vm_vec_delta_ang_norm()
543-
//the forward vector (third parameter) can be NULL, in which case the absolute
544-
//value of the angle in returned. Otherwise the angle around that vector is
545-
//returned.
546-
float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
543+
//the up vector (third parameter) can be NULL, in which case the absolute
544+
//value of the angle in returned.
545+
//Otherwise, the delta ang will be positive if the v0 -> v1 direction from the
546+
//point of view of uvec is clockwise, negative if counterclockwise.
547+
//This vector should be orthogonal to v0 and v1
548+
float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *uvec)
547549
{
548550
float t;
549551
vec3d t0,t1,t2;
550552

551553
vm_vec_copy_normalize(&t0,v0);
552554
vm_vec_copy_normalize(&t1,v1);
553555

554-
if (NULL == fvec) {
556+
if (uvec == nullptr) {
555557
t = vm_vec_delta_ang_norm(&t0, &t1, NULL);
556558
} else {
557-
vm_vec_copy_normalize(&t2,fvec);
559+
vm_vec_copy_normalize(&t2,uvec);
558560
t = vm_vec_delta_ang_norm(&t0,&t1,&t2);
559561
}
560562

561563
return t;
562564
}
563565

564566
//computes the delta angle between two normalized vectors.
565-
float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
567+
float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1, const vec3d *uvec)
566568
{
567569
float a;
568570
vec3d t;
569571

570572
a = acosf(vm_vec_dot(v0,v1));
571573

572-
if (fvec) {
574+
if (uvec) {
573575
vm_vec_cross(&t,v0,v1);
574-
if ( vm_vec_dot(&t,fvec) < 0.0 ) {
576+
if ( vm_vec_dot(&t,uvec) < 0.0 ) {
575577
a = -a;
576578
}
577579
}
578580

579581
return a;
580582
}
581583

582-
float vm_vec_delta_ang_norm_safe(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
584+
float vm_vec_delta_ang_norm_safe(const vec3d *v0, const vec3d *v1, const vec3d *uvec)
583585
{
584586
float a, dot;
585587
vec3d t;
@@ -591,9 +593,9 @@ float vm_vec_delta_ang_norm_safe(const vec3d *v0, const vec3d *v1, const vec3d *
591593

592594
a = acosf(dot);
593595

594-
if (fvec) {
596+
if (uvec) {
595597
vm_vec_cross(&t,v0,v1);
596-
if ( vm_vec_dot(&t,fvec) < 0.0 ) {
598+
if ( vm_vec_dot(&t,uvec) < 0.0 ) {
597599
a = -a;
598600
}
599601
}

code/math/vecmat.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,16 @@ vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p
224224

225225
//computes the delta angle between two vectors.
226226
//vectors need not be normalized. if they are, call vm_vec_delta_ang_norm()
227-
//the forward vector (third parameter) can be NULL, in which case the absolute
228-
//value of the angle in returned. Otherwise the angle around that vector is
229-
//returned.
230-
float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec);
227+
//the up vector (third parameter) can be NULL, in which case the absolute
228+
//value of the angle in returned.
229+
//Otherwise, the delta ang will be positive if the v0 -> v1 direction from the
230+
//point of view of uvec is clockwise, negative if counterclockwise.
231+
//This vector should be orthogonal to v0 and v1
232+
float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *uvec);
231233

232234
//computes the delta angle between two normalized vectors.
233-
float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1,const vec3d *fvec);
234-
float vm_vec_delta_ang_norm_safe(const vec3d *v0, const vec3d *v1, const vec3d *fvec);
235+
float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1,const vec3d *uvec);
236+
float vm_vec_delta_ang_norm_safe(const vec3d *v0, const vec3d *v1, const vec3d *uvec);
235237

236238
//computes a matrix from a set of three angles. returns ptr to matrix
237239
matrix *vm_angles_2_matrix(matrix *m, const angles *a);

0 commit comments

Comments
 (0)