summaryrefslogtreecommitdiff
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/lineSegmenter.cpp71
-rw-r--r--gui/src/lineSegmenter.h22
-rw-r--r--gui/src/lineTransformer.cpp127
-rw-r--r--gui/src/lineTransformer.h19
-rw-r--r--gui/src/ofApp.h2
5 files changed, 1 insertions, 240 deletions
diff --git a/gui/src/lineSegmenter.cpp b/gui/src/lineSegmenter.cpp
deleted file mode 100644
index 14f6e24..0000000
--- a/gui/src/lineSegmenter.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
- #include "lineSegmenter.h"
-
-const vector <ofPolyline> & lineSegmenter::getSegments(int num,float coverage, float phase){
- //num - number of segments
- //coverage - amount that each segment fills it's slot from 0-1
- //phase - from 0-1
-
- //if the path is closed, we can make a segment that crosses the end/beginning
- //however we want to be able to deal with open paths
-
-/*
-
-segments 0...n - 1
-phase 0...1
-
-phase 0
-
-segment 0 is (0 -> coverage) / n
-segment n - 1 is ((0 -> coverage) + (n-1)) /n
-
-phase 1: has to be the loop target, it has to look identical
-
-segment 0 is (1 -> coverage) / n
-segment n - 1 is (1 - > coverage) + (n-1)
-
-*/
-
-
- segments.clear();
-
- for (int i=0;i<num;i++){
- float startIndex=line.getIndexAtPercent((phase+i)/num); //always <1
- float endPoint=(phase+i+coverage)/num; //can be >1
- float endIndex=line.getIndexAtPercent(endPoint>1.0f?endPoint-1.0f:endPoint);
- ofPolyline segment;
- segment.addVertex(line.getPointAtIndexInterpolated(startIndex));
- for (int j=(int)ceil(startIndex);j<(endPoint>1?line.size():(int)ceil(endIndex));j++){
- segment.addVertex(line[j]);
- }
- if (endPoint>1){
- segments.push_back(segment);
- segment.clear();
- for (int j=0;j<(int)ceil(endIndex);j++){
- segment.addVertex(line[j]);
- }
- segment.addVertex(line.getPointAtIndexInterpolated(endIndex));
- }
- else {
- segment.addVertex(line.getPointAtIndexInterpolated(endIndex));
- }
- segments.push_back(segment);
- }
-
- return segments;
-}
-
-void lineSegmenter::draw(){
- line.draw();
- return;
-}
-int lineSegmenter::size(){
- return line.size();
-}
-
-
-/*
-
-
-
-
-*/ \ No newline at end of file
diff --git a/gui/src/lineSegmenter.h b/gui/src/lineSegmenter.h
deleted file mode 100644
index d858ba2..0000000
--- a/gui/src/lineSegmenter.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-
-#include "ofMain.h"
-
-class lineSegmenter{
- public:
- lineSegmenter(ofPolyline &_line){
- line=_line;
- if (line.isClosed()){
- line.addVertex(line[0]);
- }
- }
- const vector <ofPolyline> &getSegments(int num,float coverage, float phase);
- ofPolyline getPoly(){
- return line;
- }
- void draw();
- int size();
- private:
- ofPolyline line;
- vector <ofPolyline> segments;
-}; \ No newline at end of file
diff --git a/gui/src/lineTransformer.cpp b/gui/src/lineTransformer.cpp
deleted file mode 100644
index 080eb9d..0000000
--- a/gui/src/lineTransformer.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "lineTransformer.h"
-
-
-void lineTransformer::drawWarpFrame(glm::vec2 warpframe[4]){
- ofSetColor(255,255,255);
- ofNoFill();
- for (int i=0;i<4;i++){
- ofDrawCircle(warpframe[i],25);
- ofDrawLine(warpframe[i],warpframe[(i+1)%4]);
- }
-}
-
-void lineTransformer::gaussianElimination(float * input, int n)
-{
- auto i = 0;
- auto j = 0;
- auto m = n - 1;
-
- while (i < m && j < n)
- {
- auto iMax = i;
- for (auto k = i + 1; k < m; ++k)
- {
- if (fabs(input[k * n + j]) > fabs(input[iMax * n + j]))
- {
- iMax = k;
- }
- }
-
- if (input[iMax * n + j] != 0)
- {
- if (i != iMax)
- {
- for (auto k = 0; k < n; ++k)
- {
- auto ikIn = input[i * n + k];
- input[i * n + k] = input[iMax * n + k];
- input[iMax * n + k] = ikIn;
- }
- }
-
- float ijIn = input[i * n + j];
- for (auto k = 0; k < n; ++k)
- {
- input[i * n + k] /= ijIn;
- }
-
- for (auto u = i + 1; u < m; ++u)
- {
- auto ujIn = input[u * n + j];
- for (auto k = 0; k < n; ++k)
- {
- input[u * n + k] -= ujIn * input[i * n + k];
- }
- }
-
- ++i;
- }
- ++j;
- }
-
- for (auto i = m - 2; i >= 0; --i)
- {
- for (auto j = i + 1; j < n - 1; ++j)
- {
- input[i * n + m] -= input[i * n + j] * input[j * n + m];
- }
- }
-}
-
-glm::mat4 lineTransformer::getPerspectiveTransformMatrix(const glm::vec2 src[4], const glm::vec2 dst[4])
-{
- float p[8][9] =
- {
- { -src[0][0], -src[0][1], -1, 0, 0, 0, src[0][0] * dst[0][0], src[0][1] * dst[0][0], -dst[0][0] }, // h11
- { 0, 0, 0, -src[0][0], -src[0][1], -1, src[0][0] * dst[0][1], src[0][1] * dst[0][1], -dst[0][1] }, // h12
- { -src[1][0], -src[1][1], -1, 0, 0, 0, src[1][0] * dst[1][0], src[1][1] * dst[1][0], -dst[1][0] }, // h13
- { 0, 0, 0, -src[1][0], -src[1][1], -1, src[1][0] * dst[1][1], src[1][1] * dst[1][1], -dst[1][1] }, // h21
- { -src[2][0], -src[2][1], -1, 0, 0, 0, src[2][0] * dst[2][0], src[2][1] * dst[2][0], -dst[2][0] }, // h22
- { 0, 0, 0, -src[2][0], -src[2][1], -1, src[2][0] * dst[2][1], src[2][1] * dst[2][1], -dst[2][1] }, // h23
- { -src[3][0], -src[3][1], -1, 0, 0, 0, src[3][0] * dst[3][0], src[3][1] * dst[3][0], -dst[3][0] }, // h31
- { 0, 0, 0, -src[3][0], -src[3][1], -1, src[3][0] * dst[3][1], src[3][1] * dst[3][1], -dst[3][1] }, // h32
- };
-
- gaussianElimination(&p[0][0], 9);
-
- return glm::mat4(p[0][8], p[3][8], 0, p[6][8],
- p[1][8], p[4][8], 0, p[7][8],
- 0, 0, 1, 0,
- p[2][8], p[5][8], 0, 1);
-}
-
-ofPolyline lineTransformer::polyLineTransform(const ofMatrix4x4 xform, const ofPolyline& poly){
- ofPolyline tempPoly;
- for (auto& p:poly){
- tempPoly.addVertex(ofVec3f(p)*xform);
- }
- return tempPoly;
-}
-
-colourPolyline lineTransformer::polyLineTransform(const ofMatrix4x4 xform,colourPolyline& poly){
- colourPolyline tempPoly;
- for (int i=0;i<poly.size();i++){
- tempPoly.addVertex(ofVec3f(poly[i])*xform,poly.getColourAt(i));
- }
- return tempPoly;
-}
-
-
-ofPolyline lineTransformer::makePolygon(int num,float diam){
- ofPolyline poly;
- float step=PI*2/num;
- for (int i=0;i<=num;i++){
- poly.addVertex(cos(step*i)*diam,sin(step*i)*diam);
- }
- return poly;
-}
-
-void lineTransformer::drawPoly(ofPolyline poly,float x,float y){
- glPushMatrix();
- ofTranslate(x,y);
- poly.draw();
- for (int i=0;i<poly.size();i++){
- ofDrawBitmapString(poly.getDegreesAtIndex(i),poly[i].x+10,poly[i].y+10,0);
- }
- glPopMatrix();
-}
diff --git a/gui/src/lineTransformer.h b/gui/src/lineTransformer.h
deleted file mode 100644
index 4eabf14..0000000
--- a/gui/src/lineTransformer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#include "ofMain.h"
-#include "colourPolyline.h"
-
-class lineTransformer {
-
- public:
- lineTransformer(){
- }
- void static drawWarpFrame(glm::vec2 warpframe[4]);
- void static gaussianElimination(float * input, int n);
- glm::mat4 static getPerspectiveTransformMatrix(const glm::vec2 src[4], const glm::vec2 dst[4]);
- ofPolyline static polyLineTransform(const ofMatrix4x4 xform,const ofPolyline& poly);
- colourPolyline static polyLineTransform(const ofMatrix4x4 xform,colourPolyline& poly);
- ofPolyline static makePolygon(int num,float diam);
- void static drawPoly(ofPolyline poly,float x,float y);
-
-}; \ No newline at end of file
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index d0f334f..33c855a 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -1,4 +1,4 @@
-#pragma once
+ #pragma once
#include "ofMain.h"
#include "lineTransformer.h"