Back out fromSpherical code addition

This commit is contained in:
David Rowe 2015-09-24 19:14:26 -07:00
parent b2bbaf4e7b
commit d063f3488d
4 changed files with 26 additions and 30 deletions

View file

@ -58,3 +58,27 @@ glm::vec3 Vec3::toPolar(const glm::vec3& v) {
return glm::vec3(elevation, azimuth, radius);
}
glm::vec3 Vec3::fromPolar(const glm::vec3& polar) {
float x = glm::cos(polar.x) * glm::sin(polar.y);
float y = glm::sin(-polar.x);
float z = glm::cos(polar.x) * glm::cos(polar.y);
// Round small values to 0
if (glm::abs(x) < EPSILON) {
x = 0.0f;
}
if (glm::abs(y) < EPSILON) {
y = 0.0f;
}
if (glm::abs(z) < EPSILON) {
z = 0.0f;
}
return polar.z * glm::vec3(x, y, z);
}
glm::vec3 Vec3::fromPolar(float elevation, float azimuth) {
glm::vec3 v = glm::vec3(elevation, azimuth, 1.0f);
return fromPolar(v);
}

View file

@ -43,8 +43,8 @@ public slots:
bool withinEpsilon(const glm::vec3& v1, const glm::vec3& v2, float epsilon);
// FIXME misnamed, should be 'spherical' or 'euler' depending on the implementation
glm::vec3 toPolar(const glm::vec3& v);
glm::vec3 fromPolar(const glm::vec3& polar) { return fromSpherical(polar); }
glm::vec3 fromPolar(float elevation, float azimuth) { return fromSpherical(elevation, azimuth); }
glm::vec3 fromPolar(const glm::vec3& polar);
glm::vec3 fromPolar(float elevation, float azimuth);
const glm::vec3& UNIT_X() { return Vectors::UNIT_X; }
const glm::vec3& UNIT_Y() { return Vectors::UNIT_Y; }
const glm::vec3& UNIT_Z() { return Vectors::UNIT_Z; }

View file

@ -225,30 +225,6 @@ glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) {
return glm::angleAxis(angle, axis);
}
glm::vec3 fromSpherical(const glm::vec3& spherical) {
float x = glm::cos(spherical.x) * glm::sin(spherical.y);
float y = glm::sin(-spherical.x);
float z = glm::cos(spherical.x) * glm::cos(spherical.y);
// Round small values to 0
if (glm::abs(x) < EPSILON) {
x = 0.0f;
}
if (glm::abs(y) < EPSILON) {
y = 0.0f;
}
if (glm::abs(z) < EPSILON) {
z = 0.0f;
}
return spherical.z * glm::vec3(x, y, z);
}
glm::vec3 fromSpherical(float elevation, float azimuth) {
glm::vec3 v = glm::vec3(elevation, azimuth, 1.0f);
return fromSpherical(v);
}
bool isPointBehindTrianglesPlane(glm::vec3 point, glm::vec3 p0, glm::vec3 p1, glm::vec3 p2) {
glm::vec3 v1 = p0 - p1, v2 = p2 - p1; // Non-collinear vectors contained in the plane
glm::vec3 n = glm::cross(v1, v2); // Plane's normal vector, pointing out of the triangle

View file

@ -117,10 +117,6 @@ float angleBetween(const glm::vec3& v1, const glm::vec3& v2);
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2);
glm::vec3 fromSpherical(const glm::vec3& spherical);
glm::vec3 fromSpherical(float elevation, float azimuth);
bool isPointBehindTrianglesPlane(glm::vec3 point, glm::vec3 p0, glm::vec3 p1, glm::vec3 p2);
glm::vec3 extractTranslation(const glm::mat4& matrix);