From f53113f02ea5369e50bd33232db3d2b48f64cc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=C3=9F?= Date: Sun, 7 Feb 2010 16:52:50 +0100 Subject: =?UTF-8?q?Cuboid=20nicht=20ben=E4tigt=20und=20NOTNEEDED=20ordner?= =?UTF-8?q?=20hinzugef=FCgt=20und=20Fehler=20behoben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- Cuboid.cpp | 128 -------------------------------------------------- Cuboid.h | 30 ------------ House.cpp | 44 +++++++++-------- NOTNEEDED/Cuboid.cpp | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ NOTNEEDED/Cuboid.h | 30 ++++++++++++ NOTNEEDED/Verlauf.bmp | Bin 0 -> 4070 bytes Sun.cpp | 1 + Sun.h | 24 +++++----- main.cpp | 6 ++- 10 files changed, 199 insertions(+), 194 deletions(-) delete mode 100644 Cuboid.cpp delete mode 100644 Cuboid.h create mode 100644 NOTNEEDED/Cuboid.cpp create mode 100644 NOTNEEDED/Cuboid.h create mode 100644 NOTNEEDED/Verlauf.bmp create mode 100644 Sun.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b7dd82..d68742c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,11 @@ include_directories(${OPENGL_INCLUDE_DIR}) add_executable(c3d BSPTree.cpp BSPTree.h Cubehole.cpp Cubehole.h - Cuboid.cpp Cuboid.h DisplayClass.cpp DisplayClass.h gl.h House.h House.cpp main.cpp + Sun.h Sun.cpp Temparray.h Temparray.cpp Trapezocube.cpp Trapezocube.h Triangle.h diff --git a/Cuboid.cpp b/Cuboid.cpp deleted file mode 100644 index 5afae93..0000000 --- a/Cuboid.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "Cuboid.h" -#include "gl.h" - -Cuboid::Cuboid(float width, float height, float depth) { - setSize(width, height, depth); - setPos(0, 0, 0); -} - -Cuboid::Cuboid(float width, float height, float depth, float x, float y, float z) -{ - setSize(width, height, depth); - setPos(x, y, z); -} - -float Cuboid::getHeight() -{ - return height; -} - -float Cuboid::getWidth() -{ - return width; -} - -float Cuboid::getDepth() -{ - return depth; -} - -float Cuboid::getPosX() -{ - return x; -} - -float Cuboid::getPosY() -{ - return y; -} - -float Cuboid::getPosZ() -{ - return z; -} - -void Cuboid::setSize(float w, float h, float d) -{ - width = w; - height = h; - depth = d; -} - -void Cuboid::setPos(float x, float y, float z) -{ - this->x = x; - this->y = y; - this->z = z; -} - -std::list Cuboid::getTriangles() -{ - std::list triangles; - // width, height, depth - // Front face - vmml::vec4f c(0.0, 0.0, 1.0, 0.5); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), - vmml::vec3f(x-width/2, y-height/2, z+depth/2), - vmml::vec3f(x+width/2, y+height/2, z+depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z+depth/2), - vmml::vec3f(x+width/2, y-height/2, z+depth/2), - vmml::vec3f(x+width/2, y+height/2, z+depth/2), c)); - - // Back face - c = vmml::vec4f(1.0, 1.0, 0.0, 0.5); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z-depth/2), - vmml::vec3f(x+width/2, y+height/2, z-depth/2), - vmml::vec3f(x-width/2, y-height/2, z-depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z-depth/2), - vmml::vec3f(x+width/2, y+height/2, z-depth/2), - vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); - - // Left face - c = vmml::vec4f(0.0, 1.0, 0.0, 0.5); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), - vmml::vec3f(x-width/2, y+height/2, z-depth/2), - vmml::vec3f(x-width/2, y-height/2, z+depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z-depth/2), - vmml::vec3f(x-width/2, y-height/2, z+depth/2), - vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); - - // Right face - - triangles.push_back(Triangle(vmml::vec3f(x+width/2, y+height/2, z+depth/2), - vmml::vec3f(x+width/2, y-height/2, z+depth/2), - vmml::vec3f(x+width/2, y+height/2, z-depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x+width/2, y-height/2, z-depth/2), - vmml::vec3f(x+width/2, y+height/2, z-depth/2), - vmml::vec3f(x+width/2, y-height/2, z+depth/2), c)); - - // Top face - c = vmml::vec4f(1.0, 0.0, 0.0, 0.5); - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), - vmml::vec3f(x+width/2, y+height/2, z+depth/2), - vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x+width/2, y+height/2, z+depth/2), - vmml::vec3f(x+width/2, y+height/2, z-depth/2), - vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); - - // Bottom face - - triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z+depth/2), - vmml::vec3f(x-width/2, y-height/2, z-depth/2), - vmml::vec3f(x+width/2, y-height/2, z+depth/2), c)); - - triangles.push_back(Triangle(vmml::vec3f(x+width/2, y-height/2, z+depth/2), - vmml::vec3f(x-width/2, y-height/2, z-depth/2), - vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); - - return triangles; -} diff --git a/Cuboid.h b/Cuboid.h deleted file mode 100644 index d1c600d..0000000 --- a/Cuboid.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _CUBOID_H_ -#define _CUBOID_H_ - -#include "Triangle.h" - -#include - -class Cuboid -{ - public: - Cuboid() : width(0), height(0), depth(0), x(0), y(0), z(0) {} - Cuboid(float width, float height, float depth); - Cuboid(float width, float height, float depth, float x, float y, float z); - float getHeight(); - float getWidth(); - float getDepth(); - float getPosX(); - float getPosY(); - float getPosZ(); - void setSize(float w, float h, float d); - void setPos(float x, float y, float z); - std::list getTriangles(); - - private: - float width, height, depth; - float x, y, z; - -}; -#endif /*_CUBOID_H_*/ - diff --git a/House.cpp b/House.cpp index bf1724c..dca8d44 100644 --- a/House.cpp +++ b/House.cpp @@ -442,23 +442,26 @@ float x=0; // end; void House::calccollectoroutput(int day, int time, int month) { - if(collectorstatus == TRANSVERSAL) - collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)] - *anglecorrectiontransversal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] - *anglecorrectionlongitudinal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] - /**100*/; - else if(collectorstatus == LONGITUDINAL) - collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)] - *anglecorrectionlongitudinal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] - *anglecorrectiontransversal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] - /**100*/; - else if(collectorstatus == FLAT) - collectoroutput = efficiencyflat[(int)(collectortemp-tempoutside[month][time]+0.5)] - *anglecorrectionflat[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] - *anglecorrectionflat[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] - /**100*/; - - collectoroutput = collectoroutput*collectorarea*radiation; + if(sun.elevationangle(day, time) >= 0){ + if(collectorstatus == TRANSVERSAL) + collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)] + *anglecorrectiontransversal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] + *anglecorrectionlongitudinal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] + /**100*/; + else if(collectorstatus == LONGITUDINAL) + collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)] + *anglecorrectionlongitudinal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] + *anglecorrectiontransversal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] + /**100*/; + else if(collectorstatus == FLAT) + collectoroutput = efficiencyflat[(int)(collectortemp-tempoutside[month][time]+0.5)] + *anglecorrectionflat[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)] + *anglecorrectionflat[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)] + /**100*/; + + collectoroutput = collectoroutput*collectorarea*radiation; + } + else collectoroutput = 0; } void House::calcprobeinput(int day, int time, int month) { @@ -468,12 +471,13 @@ void House::calcprobeinput(int day, int time, int month) { if(E>=collectoroutput && collectoroutput>0) {E -= collectoroutput; collectoroutput=0;} else if(E0) {collectoroutput -= E; E=0;}*/ calccollectoroutput(day, time, month); - std::cout << collectoroutput << std::endl; + std::cerr << "Time: " << time << " Output: " << collectoroutput << " Watt" << std::endl; +// std::cerr << sun.elevationangle(day, time) << std::endl; collectoroutput-=neededenergy[month][time]; } void House::controller(){ - static int day=90, time=0, month=0; + static int day=0, time=0, month=0; calcprobeinput(day, time, month); temp.setprobetemp(collectortemp); temp.setinput(collectoroutput); @@ -481,7 +485,7 @@ void House::controller(){ ++time; if(time > 23){ -// std::cerr << day << " " << temp.getaverage() << std::endl; + std::cerr << day << " " << temp.getaverage() << std::endl; time = 0; ++day; } diff --git a/NOTNEEDED/Cuboid.cpp b/NOTNEEDED/Cuboid.cpp new file mode 100644 index 0000000..5afae93 --- /dev/null +++ b/NOTNEEDED/Cuboid.cpp @@ -0,0 +1,128 @@ +#include "Cuboid.h" +#include "gl.h" + +Cuboid::Cuboid(float width, float height, float depth) { + setSize(width, height, depth); + setPos(0, 0, 0); +} + +Cuboid::Cuboid(float width, float height, float depth, float x, float y, float z) +{ + setSize(width, height, depth); + setPos(x, y, z); +} + +float Cuboid::getHeight() +{ + return height; +} + +float Cuboid::getWidth() +{ + return width; +} + +float Cuboid::getDepth() +{ + return depth; +} + +float Cuboid::getPosX() +{ + return x; +} + +float Cuboid::getPosY() +{ + return y; +} + +float Cuboid::getPosZ() +{ + return z; +} + +void Cuboid::setSize(float w, float h, float d) +{ + width = w; + height = h; + depth = d; +} + +void Cuboid::setPos(float x, float y, float z) +{ + this->x = x; + this->y = y; + this->z = z; +} + +std::list Cuboid::getTriangles() +{ + std::list triangles; + // width, height, depth + // Front face + vmml::vec4f c(0.0, 0.0, 1.0, 0.5); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), c)); + + // Back face + c = vmml::vec4f(1.0, 1.0, 0.0, 0.5); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); + + // Left face + c = vmml::vec4f(0.0, 1.0, 0.0, 0.5); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); + + // Right face + + triangles.push_back(Triangle(vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x+width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), c)); + + // Top face + c = vmml::vec4f(1.0, 0.0, 0.0, 0.5); + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x+width/2, y+height/2, z+depth/2), + vmml::vec3f(x+width/2, y+height/2, z-depth/2), + vmml::vec3f(x-width/2, y+height/2, z-depth/2), c)); + + // Bottom face + + triangles.push_back(Triangle(vmml::vec3f(x-width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z+depth/2), c)); + + triangles.push_back(Triangle(vmml::vec3f(x+width/2, y-height/2, z+depth/2), + vmml::vec3f(x-width/2, y-height/2, z-depth/2), + vmml::vec3f(x+width/2, y-height/2, z-depth/2), c)); + + return triangles; +} diff --git a/NOTNEEDED/Cuboid.h b/NOTNEEDED/Cuboid.h new file mode 100644 index 0000000..d1c600d --- /dev/null +++ b/NOTNEEDED/Cuboid.h @@ -0,0 +1,30 @@ +#ifndef _CUBOID_H_ +#define _CUBOID_H_ + +#include "Triangle.h" + +#include + +class Cuboid +{ + public: + Cuboid() : width(0), height(0), depth(0), x(0), y(0), z(0) {} + Cuboid(float width, float height, float depth); + Cuboid(float width, float height, float depth, float x, float y, float z); + float getHeight(); + float getWidth(); + float getDepth(); + float getPosX(); + float getPosY(); + float getPosZ(); + void setSize(float w, float h, float d); + void setPos(float x, float y, float z); + std::list getTriangles(); + + private: + float width, height, depth; + float x, y, z; + +}; +#endif /*_CUBOID_H_*/ + diff --git a/NOTNEEDED/Verlauf.bmp b/NOTNEEDED/Verlauf.bmp new file mode 100644 index 0000000..83c0c23 Binary files /dev/null and b/NOTNEEDED/Verlauf.bmp differ diff --git a/Sun.cpp b/Sun.cpp new file mode 100644 index 0000000..158abbc --- /dev/null +++ b/Sun.cpp @@ -0,0 +1 @@ +#include "Sun.h" diff --git a/Sun.h b/Sun.h index a242e5f..6fc7857 100644 --- a/Sun.h +++ b/Sun.h @@ -12,26 +12,24 @@ class Sun void setlatitude(float latitude0){latitude=latitude0;}; float declination(int day) {return 23.4*sin(2*M_PI*(284+day+1)/365);} - float hourangle(int time) {return 15*(time+1/*-12*/);} + float hourangle(int time) {return 15*(time+1-12);} float elevationangle(int day, int time) { return asin(sin(declination(day)*M_PI/180)* - sin(latitude*M_PI/180)* + sin(latitude*M_PI/180)+ cos(hourangle(time)*M_PI/180)* cos(declination(day)*M_PI/180)* - cos(latitude*M_PI/180)) - *180/M_PI; + cos(latitude*M_PI/180))*180/M_PI; } float azimutangle(int day, int time){ - float tau, sin_tau, cos_tau, sin_phi, cos_phi, tan_dec; + float tau = hourangle(time)*M_PI/180; + float sin_tau = sin(tau); + float cos_tau = cos(tau); + float sin_phi = sin(latitude*M_PI/180); + float cos_phi = cos(latitude*M_PI/180); + float tan_dek = tan(declination(day)*M_PI/180); - tan_dec = tan(declination(day)*M_PI/180); - tau = hourangle(time)*M_PI/180; - sin_tau = sin(tau); - cos_tau = cos(tau); - sin_phi = sin(latitude*M_PI/180); - cos_phi = cos(latitude*M_PI/180); - - return atan2(sin_tau, cos_tau*sin_phi-tan_dec*cos_phi)/180*M_PI; + return atan2(sin_tau, cos_tau*sin_phi-tan_dek*cos_phi)*180/M_PI; +// return asin(cos(declination(day))*sin(elevationangle(day, time))/cos(hourangle(time))); } private: float latitude; diff --git a/main.cpp b/main.cpp index 8658424..32206e8 100644 --- a/main.cpp +++ b/main.cpp @@ -14,8 +14,10 @@ #define MIN_FRAME_DELTA 16 //#define MIN_FRAME_DELTA 41 -#define DEFAULT_WIDTH 640 -#define DEFAULT_HEIGHT 640 +//#define DEFAULT_WIDTH 640 +//#define DEFAULT_HEIGHT 640 +#define DEFAULT_HEIGHT 40 +#define DEFAULT_WIDTH 40 void initGL(bool multisample); void resize(int width, int height); -- cgit v1.2.3