mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-18 02:49:03 -06:00
Renamed pss to PowerScaledScalar
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
void rotate(const glm::quat &rotation);
|
||||
void orbit(const glm::quat &rotation);
|
||||
void distance(const pss &distance);
|
||||
void distance(const PowerScaledScalar &distance);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void orbit(const glm::quat &rotation);
|
||||
void rotate(const glm::quat &rotation);
|
||||
void distance(const pss &distance);
|
||||
void distance(const PowerScaledScalar &distance);
|
||||
|
||||
void lookAt(const glm::quat &rotation);
|
||||
void setRotation(const glm::quat &rotation);
|
||||
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool deinitialize() = 0;
|
||||
|
||||
void setBoundingSphere(const pss& boundingSphere);
|
||||
const pss& getBoundingSphere();
|
||||
void setBoundingSphere(const PowerScaledScalar& boundingSphere);
|
||||
const PowerScaledScalar& getBoundingSphere();
|
||||
|
||||
virtual void render(const Camera* camera, const psc& thisPosition) = 0;
|
||||
virtual void update();
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
protected:
|
||||
// Renderable();
|
||||
private:
|
||||
pss boundingSphere_;
|
||||
PowerScaledScalar boundingSphere_;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
const std::vector<SceneGraphNode*>& children() const;
|
||||
|
||||
// bounding sphere
|
||||
pss calculateBoundingSphere();
|
||||
PowerScaledScalar calculateBoundingSphere();
|
||||
|
||||
SceneGraphNode* get(const std::string& name);
|
||||
|
||||
@@ -92,10 +92,10 @@ private:
|
||||
|
||||
// bounding sphere
|
||||
bool _boundingSphereVisible;
|
||||
pss _boundingSphere;
|
||||
PowerScaledScalar _boundingSphere;
|
||||
|
||||
// private helper methods
|
||||
bool sphereInsideFrustum(const psc s_pos, const pss& s_rad, const Camera* camera);
|
||||
bool sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad, const Camera* camera);
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -32,7 +32,7 @@ class Planet
|
||||
{
|
||||
public:
|
||||
//initializers
|
||||
Planet(pss radius, int levels = 4);
|
||||
Planet(PowerScaledScalar radius, int levels = 4);
|
||||
~Planet();
|
||||
|
||||
void setHeightMap(const std::string &path);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace openspace
|
||||
{
|
||||
|
||||
// forward declare the power scaled scalars
|
||||
class pss;
|
||||
class PowerScaledScalar;
|
||||
|
||||
class PowerScaledCoordinate {
|
||||
public:
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
// returns the rescaled, "normal" coordinates
|
||||
glm::vec3 vec3() const;
|
||||
// length of the vector as a pss
|
||||
pss length() const;
|
||||
PowerScaledScalar length() const;
|
||||
glm::vec3 direction() const;
|
||||
|
||||
// operator overloading
|
||||
@@ -78,8 +78,8 @@ public:
|
||||
// scalar operators
|
||||
PowerScaledCoordinate operator*(const double& rhs) const;
|
||||
PowerScaledCoordinate operator*(const float& rhs) const;
|
||||
PowerScaledCoordinate& operator*=(const pss& rhs);
|
||||
PowerScaledCoordinate operator*(const pss& rhs) const;
|
||||
PowerScaledCoordinate& operator*=(const PowerScaledScalar& rhs);
|
||||
PowerScaledCoordinate operator*(const PowerScaledScalar& rhs) const;
|
||||
PowerScaledCoordinate operator*(const glm::mat4& matrix) const;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const PowerScaledCoordinate& rhs);
|
||||
|
||||
// allow the power scaled scalars to access private members
|
||||
friend class pss;
|
||||
friend class PowerScaledScalar;
|
||||
|
||||
private:
|
||||
// internal glm vector
|
||||
|
||||
@@ -34,76 +34,59 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class pss {
|
||||
class PowerScaledScalar {
|
||||
public:
|
||||
// constructors
|
||||
pss();
|
||||
pss(const glm::vec2 &v);
|
||||
pss(const glm::dvec2 &v);
|
||||
pss(const float &f1,const float &f2);
|
||||
pss(const double &d1,const double &d2);
|
||||
static pss CreatePSS(double d1);
|
||||
PowerScaledScalar();
|
||||
PowerScaledScalar(const glm::vec2 &v);
|
||||
PowerScaledScalar(float f1, float f2);
|
||||
static PowerScaledScalar CreatePSS(double d1);
|
||||
|
||||
// print n' debug
|
||||
void print() const;
|
||||
void print(const char *name) const;
|
||||
|
||||
// get functions
|
||||
const double * value_ptr();
|
||||
const float * value_ptrf();
|
||||
glm::dvec2 getVec2() const;
|
||||
glm::vec2 getVec2f() const;
|
||||
double length() const;
|
||||
const glm::vec2& vec2() const;
|
||||
float lengthf() const;
|
||||
|
||||
// operator overloading
|
||||
pss & operator=(const pss &rhs);
|
||||
pss & operator+=(const pss &rhs);
|
||||
const pss operator+(const pss &rhs) const;
|
||||
pss & operator-=(const pss &rhs);
|
||||
const pss operator-(const pss &rhs) const;
|
||||
pss & operator*=(const pss &rhs);
|
||||
const pss operator*(const pss &rhs) const;
|
||||
pss & operator*=(const double &rhs);
|
||||
const pss operator*(const double &rhs) const;
|
||||
pss & operator*=(const float &rhs);
|
||||
const pss operator*(const float &rhs) const;
|
||||
double& operator[](unsigned int idx);
|
||||
const double& operator[](unsigned int idx) const;
|
||||
PowerScaledScalar& operator=(const PowerScaledScalar& rhs);
|
||||
PowerScaledScalar& operator+=(const PowerScaledScalar& rhs);
|
||||
const PowerScaledScalar operator+(const PowerScaledScalar& rhs) const;
|
||||
PowerScaledScalar& operator-=(const PowerScaledScalar& rhs);
|
||||
const PowerScaledScalar operator-(const PowerScaledScalar& rhs) const;
|
||||
PowerScaledScalar& operator*=(const PowerScaledScalar& rhs);
|
||||
const PowerScaledScalar operator*(const PowerScaledScalar& rhs) const;
|
||||
PowerScaledScalar& operator*=(const float& rhs);
|
||||
const PowerScaledScalar operator*(const float& rhs) const;
|
||||
float& operator[](unsigned int idx);
|
||||
float operator[](unsigned int idx) const;
|
||||
|
||||
// comparasion
|
||||
bool operator==(const pss &other) const;
|
||||
bool operator<(const pss &other) const;
|
||||
bool operator>(const pss &other) const;
|
||||
bool operator<=(const pss &other) const;
|
||||
bool operator>=(const pss &other) const;
|
||||
// comparison
|
||||
bool operator==(const PowerScaledScalar& other) const;
|
||||
bool operator<(const PowerScaledScalar& other) const;
|
||||
bool operator>(const PowerScaledScalar& other) const;
|
||||
bool operator<=(const PowerScaledScalar& other) const;
|
||||
bool operator>=(const PowerScaledScalar& other) const;
|
||||
|
||||
bool operator==(const double &other) const;
|
||||
bool operator<(const double &other) const;
|
||||
bool operator>(const double &other) const;
|
||||
bool operator<=(const double &other) const;
|
||||
bool operator>=(const double &other) const;
|
||||
bool operator==(double other) const;
|
||||
bool operator<(double other) const;
|
||||
bool operator>(double other) const;
|
||||
bool operator<=(double other) const;
|
||||
bool operator>=(double other) const;
|
||||
|
||||
// glm integration
|
||||
pss & operator=(const glm::vec2 &rhs);
|
||||
pss & operator=(const float &rhs);
|
||||
pss & operator=(const glm::dvec2 &rhs);
|
||||
pss & operator=(const double &rhs);
|
||||
PowerScaledScalar& operator=(const glm::vec2& rhs);
|
||||
PowerScaledScalar& operator=(float rhs);
|
||||
|
||||
friend std::ostream& operator<<(::std::ostream& os, const pss& rhs);
|
||||
friend std::ostream& operator<<(std::ostream& os, const PowerScaledScalar& rhs);
|
||||
|
||||
// allow the power scaled coordinates to acces private members
|
||||
// allow the power scaled coordinates to access private members
|
||||
friend class PowerScaledCoordinate;
|
||||
private:
|
||||
|
||||
// internal glm vector
|
||||
glm::dvec2 vec_;
|
||||
|
||||
// float vector used when returning float values
|
||||
mutable glm::vec2 vecf_;
|
||||
glm::vec2 _data;
|
||||
|
||||
};
|
||||
|
||||
typedef PowerScaledScalar pss;
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace openspace {
|
||||
class PowerScaledSphere {
|
||||
public:
|
||||
// initializers
|
||||
PowerScaledSphere(const pss& radius, int segments = 8);
|
||||
PowerScaledSphere(const PowerScaledScalar& radius, int segments = 8);
|
||||
~PowerScaledSphere();
|
||||
|
||||
bool initialize();
|
||||
|
||||
@@ -24,7 +24,7 @@ void ExternalControl::orbit(const glm::quat &rotation) {
|
||||
OsEng.interactionHandler().orbit(rotation);
|
||||
}
|
||||
|
||||
void ExternalControl::distance(const pss &distance) {
|
||||
void ExternalControl::distance(const PowerScaledScalar &distance) {
|
||||
OsEng.interactionHandler().distance(distance);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ void InteractionHandler::orbit(const glm::quat &rotation) {
|
||||
unlockControls();
|
||||
}
|
||||
|
||||
void InteractionHandler::distance(const pss &distance) {
|
||||
void InteractionHandler::distance(const PowerScaledScalar &distance) {
|
||||
//assert(this_);
|
||||
lockControls();
|
||||
|
||||
@@ -179,7 +179,7 @@ void InteractionHandler::distance(const pss &distance) {
|
||||
}
|
||||
|
||||
psc relative_origin_coordinate = relative - origin;
|
||||
glm::dvec3 dir(relative_origin_coordinate.direction());
|
||||
glm::vec3 dir(relative_origin_coordinate.direction());
|
||||
dir = dir * distance[0];
|
||||
relative_origin_coordinate = dir;
|
||||
relative_origin_coordinate[3] = distance[1];
|
||||
@@ -344,19 +344,19 @@ void InteractionHandler::keyboardCallback(int key, int action) {
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 'R') {
|
||||
pss dist(-speed * dt, 0.0);
|
||||
PowerScaledScalar dist(-speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'F') {
|
||||
pss dist(speed * dt, 0.0);
|
||||
PowerScaledScalar dist(speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'T') {
|
||||
pss dist(-speed * 100.0 * dt, 0.0);
|
||||
PowerScaledScalar dist(-speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'G') {
|
||||
pss dist(speed * 100.0 * dt, 0.0);
|
||||
PowerScaledScalar dist(speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -119,7 +119,7 @@ void RenderablePlanet::render(const Camera* camera, const psc& thisPosition)
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
pss scaling = camera->scaling();
|
||||
PowerScaledScalar scaling = camera->scaling();
|
||||
|
||||
// scale the planet to appropriate size since the planet is a unit sphere
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
@@ -133,7 +133,7 @@ void RenderablePlanet::render(const Camera* camera, const psc& thisPosition)
|
||||
_programObject->setUniform("campos", campos.vec4());
|
||||
_programObject->setUniform("objpos", currentPosition.vec4());
|
||||
_programObject->setUniform("camrot", camrot);
|
||||
_programObject->setUniform("scaling", scaling.getVec2f());
|
||||
_programObject->setUniform("scaling", scaling.vec2());
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
@@ -107,7 +107,7 @@ void SimpleSphereGeometry::createSphere()
|
||||
{
|
||||
//create the power scaled scalar
|
||||
|
||||
pss planetSize(_radius);
|
||||
PowerScaledScalar planetSize(_radius);
|
||||
_parent->setBoundingSphere(planetSize);
|
||||
|
||||
delete _planet;
|
||||
|
||||
@@ -69,12 +69,12 @@ Renderable::~Renderable()
|
||||
{
|
||||
}
|
||||
|
||||
void Renderable::setBoundingSphere(const pss& boundingSphere)
|
||||
void Renderable::setBoundingSphere(const PowerScaledScalar& boundingSphere)
|
||||
{
|
||||
boundingSphere_ = boundingSphere;
|
||||
}
|
||||
|
||||
const pss& Renderable::getBoundingSphere()
|
||||
const PowerScaledScalar& Renderable::getBoundingSphere()
|
||||
{
|
||||
return boundingSphere_;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ RenderableVolumeExpert::RenderableVolumeExpert(const ghoul::Dictionary& dictiona
|
||||
}
|
||||
}
|
||||
|
||||
setBoundingSphere(pss::CreatePSS(_boxScaling.length()));
|
||||
setBoundingSphere(PowerScaledScalar::CreatePSS(_boxScaling.length()));
|
||||
}
|
||||
|
||||
RenderableVolumeExpert::~RenderableVolumeExpert() {
|
||||
|
||||
@@ -178,7 +178,7 @@ void RenderEngine::render()
|
||||
const glm::vec3 viewdirection = _mainCamera->viewDirection();
|
||||
const psc position = _mainCamera->position();
|
||||
const psc origin = OsEng.interactionHandler().getOrigin();
|
||||
const pss pssl = (position - origin).length();
|
||||
const PowerScaledScalar pssl = (position - origin).length();
|
||||
|
||||
Freetype::print(
|
||||
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
|
||||
|
||||
@@ -177,10 +177,10 @@ bool SceneGraph::initialize()
|
||||
// TODO: Set distance and camera direction in some more smart way
|
||||
// TODO: Set scaling dependent on the position and distance
|
||||
// set position for camera
|
||||
const pss bound = positionNode->calculateBoundingSphere();
|
||||
const PowerScaledScalar bound = positionNode->calculateBoundingSphere();
|
||||
|
||||
// this part is full of magic!
|
||||
glm::vec2 boundf = bound.getVec2f();
|
||||
glm::vec2 boundf = bound.vec2();
|
||||
glm::vec2 scaling{1.0f, -boundf[1]};
|
||||
boundf[0] *= 5.0f;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ bool SceneGraphNode::deinitialize()
|
||||
_nodeName = "";
|
||||
_renderableVisible = false;
|
||||
_boundingSphereVisible = false;
|
||||
_boundingSphere = pss(0.0, 0.0);
|
||||
_boundingSphere = PowerScaledScalar(0.0, 0.0);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -270,20 +270,20 @@ const std::vector<SceneGraphNode*>& SceneGraphNode::children() const
|
||||
}
|
||||
|
||||
// bounding sphere
|
||||
pss SceneGraphNode::calculateBoundingSphere()
|
||||
PowerScaledScalar SceneGraphNode::calculateBoundingSphere()
|
||||
{
|
||||
// set the bounding sphere to 0.0
|
||||
_boundingSphere = 0.0;
|
||||
|
||||
if (_children.size() > 0) { // node
|
||||
pss maxChild;
|
||||
PowerScaledScalar maxChild;
|
||||
|
||||
// loop though all children and find the one furthest away/with the largest
|
||||
// bounding sphere
|
||||
for (size_t i = 0; i < _children.size(); ++i) {
|
||||
// when positions is dynamic, change this part to fins the most distant
|
||||
// position
|
||||
pss child = _children.at(i)->getPosition().length()
|
||||
PowerScaledScalar child = _children.at(i)->getPosition().length()
|
||||
+ _children.at(i)->calculateBoundingSphere();
|
||||
if (child > maxChild) {
|
||||
maxChild = child;
|
||||
@@ -313,7 +313,7 @@ const Renderable* SceneGraphNode::getRenderable() const
|
||||
}
|
||||
|
||||
// private helper methods
|
||||
bool SceneGraphNode::sphereInsideFrustum(const psc s_pos, const pss& s_rad,
|
||||
bool SceneGraphNode::sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad,
|
||||
const Camera* camera)
|
||||
{
|
||||
// direction the camera is looking at in power scale
|
||||
|
||||
@@ -20,7 +20,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
namespace openspace
|
||||
{
|
||||
|
||||
Planet::Planet(pss radius, int levels) {
|
||||
Planet::Planet(PowerScaledScalar radius, int levels) {
|
||||
|
||||
// describe datatype and Vertex structure to the vbo template
|
||||
std::vector<std::tuple<int, GLenum, int> > descriptor;
|
||||
|
||||
@@ -95,9 +95,9 @@ glm::vec3 PowerScaledCoordinate::vec3() const
|
||||
_vec[2] * pow(k, _vec[3]));
|
||||
}
|
||||
|
||||
pss PowerScaledCoordinate::length() const
|
||||
PowerScaledScalar PowerScaledCoordinate::length() const
|
||||
{
|
||||
return pss(glm::length(glm::vec3(_vec[0], _vec[1], _vec[2])), _vec[3]);
|
||||
return PowerScaledScalar(glm::length(glm::vec3(_vec[0], _vec[1], _vec[2])), _vec[3]);
|
||||
}
|
||||
|
||||
glm::vec3 PowerScaledCoordinate::direction() const
|
||||
@@ -195,24 +195,24 @@ PowerScaledCoordinate PowerScaledCoordinate::operator*(const float& rhs) const
|
||||
return PowerScaledCoordinate(_vec[0] * rhs, _vec[1] * rhs, _vec[2] * rhs, _vec[3]);
|
||||
}
|
||||
|
||||
PowerScaledCoordinate& PowerScaledCoordinate::operator*=(const pss& rhs)
|
||||
PowerScaledCoordinate& PowerScaledCoordinate::operator*=(const PowerScaledScalar& rhs)
|
||||
{
|
||||
double ds = this->_vec[3] - rhs.vec_[1];
|
||||
double ds = this->_vec[3] - rhs._data[1];
|
||||
if (ds >= 0) {
|
||||
double p = pow(k, -ds);
|
||||
*this = PowerScaledCoordinate(
|
||||
rhs.vec_[0] * p * _vec[0], rhs.vec_[0] * p * _vec[1],
|
||||
rhs.vec_[0] * p * _vec[2], this->_vec[3] + _vec[3]);
|
||||
rhs._data[0] * p * _vec[0], rhs._data[0] * p * _vec[1],
|
||||
rhs._data[0] * p * _vec[2], this->_vec[3] + _vec[3]);
|
||||
} else {
|
||||
double p = pow(k, ds);
|
||||
*this = PowerScaledCoordinate(
|
||||
rhs.vec_[0] * _vec[0] * p, rhs.vec_[0] * _vec[1] * p,
|
||||
rhs.vec_[0] * _vec[2] * p, rhs.vec_[1] + rhs.vec_[1]);
|
||||
rhs._data[0] * _vec[0] * p, rhs._data[0] * _vec[1] * p,
|
||||
rhs._data[0] * _vec[2] * p, rhs._data[1] + rhs._data[1]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
PowerScaledCoordinate PowerScaledCoordinate::operator*(const pss& rhs) const
|
||||
PowerScaledCoordinate PowerScaledCoordinate::operator*(const PowerScaledScalar& rhs) const
|
||||
{
|
||||
return PowerScaledCoordinate(*this) *= rhs;
|
||||
}
|
||||
|
||||
@@ -37,27 +37,19 @@ namespace openspace {
|
||||
}
|
||||
|
||||
|
||||
pss::pss() {
|
||||
PowerScaledScalar::PowerScaledScalar() : _data(0.f) {
|
||||
|
||||
}
|
||||
|
||||
pss::pss(const glm::vec2 &v) {
|
||||
vec_ = glm::dvec2(v);
|
||||
PowerScaledScalar::PowerScaledScalar(const glm::vec2 &v) {
|
||||
_data = std::move(v);
|
||||
}
|
||||
|
||||
pss::pss(const glm::dvec2 &v) {
|
||||
vec_ = v;
|
||||
PowerScaledScalar::PowerScaledScalar(float f1, float f2) {
|
||||
_data = glm::vec2(f1, f2);
|
||||
}
|
||||
|
||||
pss::pss(const float &f1,const float &f2) {
|
||||
vec_ = glm::dvec2(f1, f2);
|
||||
}
|
||||
|
||||
pss::pss(const double &d1,const double &d2) {
|
||||
vec_ = glm::dvec2(d1, d2);
|
||||
}
|
||||
|
||||
pss pss::CreatePSS(double d1) {
|
||||
PowerScaledScalar PowerScaledScalar::CreatePSS(double d1) {
|
||||
char buff[30];
|
||||
|
||||
// find the number with maximum number of digits
|
||||
@@ -69,237 +61,187 @@ pss pss::CreatePSS(double d1) {
|
||||
|
||||
// rescale and return
|
||||
double tp = 1.0 / pow(k, digits);
|
||||
return pss(d1*tp, digits);
|
||||
return PowerScaledScalar(d1*tp, digits);
|
||||
}
|
||||
|
||||
void pss::print() const {
|
||||
std::printf("[\n %f\n %f\n]\n",vec_[0], vec_[1]);
|
||||
}
|
||||
void pss::print(const char *name) const {
|
||||
std::printf("%s = [\n %f\n %f\n]\n", name, vec_[0], vec_[1]);
|
||||
const glm::vec2& PowerScaledScalar::vec2() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
const double * pss::value_ptr() {
|
||||
return glm::value_ptr(vec_);
|
||||
float PowerScaledScalar::lengthf() const {
|
||||
return static_cast<float>(_data[0] * pow(k,_data[1]));
|
||||
}
|
||||
|
||||
const float * pss::value_ptrf() {
|
||||
// need existing variable to return pointer to, local variables perish..
|
||||
vecf_ = glm::vec2(vec_);
|
||||
return glm::value_ptr(vecf_);
|
||||
}
|
||||
|
||||
glm::dvec2 pss::getVec2() const{
|
||||
return vec_;
|
||||
}
|
||||
|
||||
glm::vec2 pss::getVec2f() const {
|
||||
vecf_ = glm::vec2(vec_);
|
||||
return vecf_;
|
||||
}
|
||||
|
||||
double pss::length() const {
|
||||
return vec_[0] * pow(k,vec_[1]);
|
||||
}
|
||||
|
||||
float pss::lengthf() const {
|
||||
return static_cast<float>(vec_[0] * pow(k,vec_[1]));
|
||||
}
|
||||
|
||||
pss& pss::operator=(const pss &rhs) {
|
||||
PowerScaledScalar& PowerScaledScalar::operator=(const PowerScaledScalar &rhs) {
|
||||
if (this != &rhs){
|
||||
this->vec_ = rhs.vec_;
|
||||
this->_data = rhs._data;
|
||||
}
|
||||
return *this; // Return a reference to myself.
|
||||
}
|
||||
|
||||
pss & pss::operator=(const glm::vec2 &rhs) {
|
||||
this->vec_ = glm::dvec2(rhs);
|
||||
PowerScaledScalar & PowerScaledScalar::operator=(const glm::vec2 &rhs) {
|
||||
this->_data = glm::vec2(rhs);
|
||||
return *this; // Return a reference to myself.
|
||||
}
|
||||
|
||||
pss & pss::operator=(const float &rhs) {
|
||||
this->vec_ = glm::dvec2(rhs,0.0);
|
||||
PowerScaledScalar & PowerScaledScalar::operator=(float rhs) {
|
||||
this->_data = glm::vec2(rhs,0.0);
|
||||
return *this; // Return a reference to myself.
|
||||
}
|
||||
|
||||
pss & pss::operator=(const glm::dvec2 &rhs) {
|
||||
this->vec_ = rhs;
|
||||
return *this; // Return a reference to myself.
|
||||
}
|
||||
PowerScaledScalar & PowerScaledScalar::operator+=(const PowerScaledScalar &rhs) {
|
||||
|
||||
pss & pss::operator=(const double&rhs) {
|
||||
this->vec_ = glm::dvec2(rhs,0.0);
|
||||
return *this; // Return a reference to myself.
|
||||
}
|
||||
|
||||
pss & pss::operator+=(const pss &rhs) {
|
||||
|
||||
double ds = this->vec_[1] - rhs.vec_[1];
|
||||
double ds = this->_data[1] - rhs._data[1];
|
||||
if(ds >= 0) {
|
||||
*this = pss(rhs.vec_[0]*pow(k,-ds) + this->vec_[0], this->vec_[1]);
|
||||
*this = PowerScaledScalar(rhs._data[0]*pow(k,-ds) + this->_data[0], this->_data[1]);
|
||||
} else {
|
||||
*this = pss(rhs.vec_[0] + this->vec_[0]*pow(k,ds), rhs.vec_[1]);
|
||||
*this = PowerScaledScalar(rhs._data[0] + this->_data[0]*pow(k,ds), rhs._data[1]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const pss pss::operator+(const pss &rhs) const {
|
||||
return pss(*this) += rhs;
|
||||
const PowerScaledScalar PowerScaledScalar::operator+(const PowerScaledScalar &rhs) const {
|
||||
return PowerScaledScalar(*this) += rhs;
|
||||
}
|
||||
|
||||
pss & pss::operator-=(const pss &rhs) {
|
||||
PowerScaledScalar & PowerScaledScalar::operator-=(const PowerScaledScalar &rhs) {
|
||||
|
||||
double ds = this->vec_[1] - rhs.vec_[1];
|
||||
double ds = this->_data[1] - rhs._data[1];
|
||||
if(ds >= 0) {
|
||||
*this = pss(-rhs.vec_[0]*pow(k,-ds) + this->vec_[0], this->vec_[1]);
|
||||
*this = PowerScaledScalar(-rhs._data[0]*pow(k,-ds) + this->_data[0], this->_data[1]);
|
||||
} else {
|
||||
*this = pss(-rhs.vec_[0] + this->vec_[0]*pow(k,ds), rhs.vec_[1]);
|
||||
*this = PowerScaledScalar(-rhs._data[0] + this->_data[0]*pow(k,ds), rhs._data[1]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const pss pss::operator-(const pss &rhs) const {
|
||||
return pss(*this) -= rhs;
|
||||
const PowerScaledScalar PowerScaledScalar::operator-(const PowerScaledScalar &rhs) const {
|
||||
return PowerScaledScalar(*this) -= rhs;
|
||||
}
|
||||
|
||||
pss & pss::operator*=(const pss &rhs) {
|
||||
double ds = this->vec_[1] - rhs.vec_[1];
|
||||
PowerScaledScalar & PowerScaledScalar::operator*=(const PowerScaledScalar &rhs) {
|
||||
double ds = this->_data[1] - rhs._data[1];
|
||||
if(ds >= 0) {
|
||||
*this = pss(rhs.vec_[0]*pow(k,-ds) * this->vec_[0], this->vec_[1]+this->vec_[1]);
|
||||
*this = PowerScaledScalar(rhs._data[0]*pow(k,-ds) * this->_data[0], this->_data[1]+this->_data[1]);
|
||||
} else {
|
||||
*this = pss(rhs.vec_[0] * this->vec_[0]*pow(k,ds), rhs.vec_[1]+rhs.vec_[1]);
|
||||
*this = PowerScaledScalar(rhs._data[0] * this->_data[0]*pow(k,ds), rhs._data[1]+rhs._data[1]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
const pss pss::operator*(const pss &rhs) const {
|
||||
return pss(*this) *= rhs;
|
||||
const PowerScaledScalar PowerScaledScalar::operator*(const PowerScaledScalar &rhs) const {
|
||||
return PowerScaledScalar(*this) *= rhs;
|
||||
}
|
||||
|
||||
pss & pss::operator*=(const double &rhs) {
|
||||
double ds = this->vec_[1];
|
||||
|
||||
PowerScaledScalar & PowerScaledScalar::operator*=(const float &rhs) {
|
||||
double ds = this->_data[1];
|
||||
if(ds >= 0) {
|
||||
*this = pss(rhs*pow(k,-ds) * this->vec_[0], this->vec_[1]);
|
||||
*this = PowerScaledScalar(rhs*pow(k,-ds) * this->_data[0],this->_data[1]+this->_data[1]);
|
||||
} else {
|
||||
*this = pss(rhs * this->vec_[0]*pow(k,ds), 0.0);
|
||||
*this = PowerScaledScalar(rhs * this->_data[0]*pow(k,ds), 0.0);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
const pss pss::operator*(const double &rhs) const {
|
||||
return pss(*this) *= rhs;
|
||||
const PowerScaledScalar PowerScaledScalar::operator*(const float &rhs) const {
|
||||
return PowerScaledScalar(*this) *= rhs;
|
||||
}
|
||||
|
||||
pss & pss::operator*=(const float &rhs) {
|
||||
double ds = this->vec_[1];
|
||||
float& PowerScaledScalar::operator[](unsigned int idx) {
|
||||
return _data[idx];
|
||||
}
|
||||
|
||||
float PowerScaledScalar::operator[](unsigned int idx) const {
|
||||
return _data[idx];
|
||||
}
|
||||
|
||||
bool PowerScaledScalar::operator==(const PowerScaledScalar &other) const {
|
||||
return _data == other._data;
|
||||
}
|
||||
|
||||
bool PowerScaledScalar::operator<(const PowerScaledScalar &other) const {
|
||||
double ds = this->_data[1] - other._data[1];
|
||||
if(ds >= 0) {
|
||||
*this = pss(rhs*pow(k,-ds) * this->vec_[0],this->vec_[1]+this->vec_[1]);
|
||||
} else {
|
||||
*this = pss(rhs * this->vec_[0]*pow(k,ds), 0.0);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const pss pss::operator*(const float &rhs) const {
|
||||
return pss(*this) *= rhs;
|
||||
}
|
||||
|
||||
double& pss::operator[](unsigned int idx) {
|
||||
return vec_[idx];
|
||||
}
|
||||
const double& pss::operator[](unsigned int idx) const {
|
||||
return vec_[idx];
|
||||
}
|
||||
|
||||
bool pss::operator==(const pss &other) const {
|
||||
return vec_ == other.vec_;
|
||||
}
|
||||
|
||||
bool pss::operator<(const pss &other) const {
|
||||
double ds = this->vec_[1] - other.vec_[1];
|
||||
if(ds >= 0) {
|
||||
double upscaled = other.vec_[0]*pow(k,-ds);
|
||||
return vec_[0] < upscaled;
|
||||
double upscaled = other._data[0]*pow(k,-ds);
|
||||
return _data[0] < upscaled;
|
||||
/*
|
||||
bool retur =(vec_[0] < upscaled);
|
||||
std::printf("this: %f, upscaled: %f, this<upscaled: %i\n", vec_[0], upscaled, retur);
|
||||
return retur;
|
||||
*/
|
||||
} else {
|
||||
double upscaled = vec_[0]*pow(k,-ds);
|
||||
return other.vec_[0] > upscaled;
|
||||
double upscaled = _data[0]*pow(k,-ds);
|
||||
return other._data[0] > upscaled;
|
||||
}
|
||||
}
|
||||
|
||||
bool pss::operator>(const pss &other) const {
|
||||
double ds = this->vec_[1] - other.vec_[1];
|
||||
bool PowerScaledScalar::operator>(const PowerScaledScalar &other) const {
|
||||
double ds = this->_data[1] - other._data[1];
|
||||
if(ds >= 0) {
|
||||
double upscaled = other.vec_[0]*pow(k,-ds);
|
||||
return vec_[0] > upscaled;
|
||||
double upscaled = other._data[0]*pow(k,-ds);
|
||||
return _data[0] > upscaled;
|
||||
} else {
|
||||
double upscaled = vec_[0]*pow(k,-ds);
|
||||
return other.vec_[0] < upscaled;
|
||||
double upscaled = _data[0]*pow(k,-ds);
|
||||
return other._data[0] < upscaled;
|
||||
}
|
||||
}
|
||||
|
||||
bool pss::operator<=(const pss &other) const {
|
||||
bool PowerScaledScalar::operator<=(const PowerScaledScalar &other) const {
|
||||
return *this < other || *this == other;
|
||||
}
|
||||
|
||||
bool pss::operator>=(const pss &other) const {
|
||||
bool PowerScaledScalar::operator>=(const PowerScaledScalar &other) const {
|
||||
return *this > other || *this == other;
|
||||
}
|
||||
|
||||
bool pss::operator==(const double &other) const {
|
||||
double ds = this->vec_[1];
|
||||
bool PowerScaledScalar::operator==(double other) const {
|
||||
double ds = this->_data[1];
|
||||
if(ds >= 0) {
|
||||
double upscaled = other*pow(k,-ds);
|
||||
return vec_[0] == upscaled;
|
||||
return _data[0] == upscaled;
|
||||
} else {
|
||||
double upscaled = vec_[0]*pow(k,-ds);
|
||||
double upscaled = _data[0]*pow(k,-ds);
|
||||
return other == upscaled;
|
||||
}
|
||||
}
|
||||
|
||||
bool pss::operator<(const double &other) const {
|
||||
double ds = this->vec_[1];
|
||||
bool PowerScaledScalar::operator<(double other) const {
|
||||
double ds = this->_data[1];
|
||||
if(ds >= 0) {
|
||||
double upscaled = other*pow(k,-ds);
|
||||
return vec_[0] < upscaled;
|
||||
return _data[0] < upscaled;
|
||||
} else {
|
||||
double upscaled = vec_[0]*pow(k,-ds);
|
||||
double upscaled = _data[0]*pow(k,-ds);
|
||||
return other > upscaled;
|
||||
}
|
||||
}
|
||||
|
||||
bool pss::operator>(const double &other) const {
|
||||
double ds = this->vec_[1];
|
||||
bool PowerScaledScalar::operator>(double other) const {
|
||||
double ds = this->_data[1];
|
||||
if(ds >= 0) {
|
||||
double upscaled = other*pow(k,-ds);
|
||||
return vec_[0] > upscaled;
|
||||
return _data[0] > upscaled;
|
||||
} else {
|
||||
double upscaled = vec_[0]*pow(k,-ds);
|
||||
double upscaled = _data[0]*pow(k,-ds);
|
||||
return other < upscaled;
|
||||
}
|
||||
}
|
||||
|
||||
bool pss::operator<=(const double &other) const {
|
||||
bool PowerScaledScalar::operator<=(double other) const {
|
||||
return *this < other || *this == other;
|
||||
}
|
||||
|
||||
bool pss::operator>=(const double &other) const {
|
||||
bool PowerScaledScalar::operator>=(double other) const {
|
||||
return *this > other || *this == other;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(::std::ostream& os, const pss& rhs) {
|
||||
std::ostream& operator<<(::std::ostream& os, const PowerScaledScalar& rhs) {
|
||||
os << "(" << rhs[0] << ", " << rhs[1] << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const std::string _loggerCat = "PowerScaledSphere";
|
||||
|
||||
namespace openspace {
|
||||
|
||||
PowerScaledSphere::PowerScaledSphere(const pss& radius, int segments)
|
||||
PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segments)
|
||||
: _vaoID(0)
|
||||
, _vBufferID(0)
|
||||
, _iBufferID(0)
|
||||
|
||||
Reference in New Issue
Block a user