Commented angle utility function

This commit is contained in:
Philip Rosedale 2013-01-24 17:47:46 -08:00
parent e88c64ee92
commit 7b9df9aae6
3 changed files with 5 additions and 6 deletions

View file

@ -257,11 +257,10 @@ void display_stats(void)
#endif
char adc[200];
sprintf(adc, "location = %3.1f,%3.1f,%3.1f, angle_to 0,0,0 = %3.1f, head yaw = %3.1f, render_yaw = %3.1f, together = %3.1f",
sprintf(adc, "location = %3.1f,%3.1f,%3.1f, angle_to(origin) = %3.1f, head yaw = %3.1f, render_yaw = %3.1f",
-location[0], -location[1], -location[2],
azimuth_to(myHead.getPos()*-1.f, glm::vec3(0,0,0)),
myHead.getYaw(), render_yaw,
angle_to(myHead.getPos()*-1.f, glm::vec3(0,0,0), render_yaw, myHead.getYaw())
angle_to(myHead.getPos()*-1.f, glm::vec3(0,0,0), render_yaw, myHead.getYaw()),
myHead.getYaw(), render_yaw
);
drawtext(10, 50, 0.10, 0, 1.0, 0, adc);

View file

@ -19,12 +19,12 @@ float randFloat () {
return (rand()%10000)/10000.f;
}
// Return the azimuth angle in degrees between a head position and a sound source,
// given the two positions.
// Return the azimuth angle in degrees between two points.
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos) {
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI;
}
// Return the angle in degrees between the head and an object in the scene. The value is zero if you are looking right at it. The angle is negative if the object is to your right.
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw) {
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI + render_yaw + head_yaw;
}