dungeon_crawler

view prototype/vmath/sphvec.cc @ 61:4472ef41a209

forgot an extra mrt uniform in deferred_omni.p.glsl
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Sep 2012 06:37:56 +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 }