goat3d
annotate libs/vmath/sphvec.cc @ 29:3d669155709d
- switched the unix build to use the internal vmath/anim as well
- fixed a memory corruption issue which was caused by including the system-wide
installed version of the anim.h header file
- started the ass2goat assimp->goat3d converter
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 29 Sep 2013 21:53:03 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@27 | 1 #include "sphvec.h" |
nuclear@27 | 2 #include "vector.h" |
nuclear@27 | 3 |
nuclear@27 | 4 /* theta: 0 <= theta <= 2pi, the angle around Y axis. |
nuclear@27 | 5 * phi: 0 <= phi <= pi, the angle from Y axis. |
nuclear@27 | 6 * r: radius. |
nuclear@27 | 7 */ |
nuclear@27 | 8 SphVector::SphVector(scalar_t theta, scalar_t phi, scalar_t r) { |
nuclear@27 | 9 this->theta = theta; |
nuclear@27 | 10 this->phi = phi; |
nuclear@27 | 11 this->r = r; |
nuclear@27 | 12 } |
nuclear@27 | 13 |
nuclear@27 | 14 /* Constructs a spherical coordinate vector from a cartesian vector */ |
nuclear@27 | 15 SphVector::SphVector(const Vector3 &cvec) { |
nuclear@27 | 16 *this = cvec; |
nuclear@27 | 17 } |
nuclear@27 | 18 |
nuclear@27 | 19 /* Assignment operator that converts cartesian to spherical coords */ |
nuclear@27 | 20 SphVector &SphVector::operator =(const Vector3 &cvec) { |
nuclear@27 | 21 r = cvec.length(); |
nuclear@27 | 22 //theta = atan2(cvec.y, cvec.x); |
nuclear@27 | 23 theta = atan2(cvec.z, cvec.x); |
nuclear@27 | 24 //phi = acos(cvec.z / r); |
nuclear@27 | 25 phi = acos(cvec.y / r); |
nuclear@27 | 26 return *this; |
nuclear@27 | 27 } |