goat3d

view 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
line source
1 #include "sphvec.h"
2 #include "vector.h"
4 /* theta: 0 <= theta <= 2pi, the angle around Y axis.
5 * phi: 0 <= phi <= pi, the angle from Y axis.
6 * r: radius.
7 */
8 SphVector::SphVector(scalar_t theta, scalar_t phi, scalar_t r) {
9 this->theta = theta;
10 this->phi = phi;
11 this->r = r;
12 }
14 /* Constructs a spherical coordinate vector from a cartesian vector */
15 SphVector::SphVector(const Vector3 &cvec) {
16 *this = cvec;
17 }
19 /* Assignment operator that converts cartesian to spherical coords */
20 SphVector &SphVector::operator =(const Vector3 &cvec) {
21 r = cvec.length();
22 //theta = atan2(cvec.y, cvec.x);
23 theta = atan2(cvec.z, cvec.x);
24 //phi = acos(cvec.z / r);
25 phi = acos(cvec.y / r);
26 return *this;
27 }