Last active
February 4, 2020 19:25
-
-
Save roymacdonald/88a63e9213040c9b95443fbc56224135 to your computer and use it in GitHub Desktop.
Clotoid curve test (openFrameworks code)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
gui.setup(); | |
gui.add(T); | |
gui.add(scale); | |
gui.add(N); | |
gui.add(inc.set("Angle Increment", T/(float)N, 0, 0.1)); | |
gui.add(startT); | |
gui.add(power); | |
gui.add(startPoint); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
float t=startT.get(); | |
glm::vec2 d; | |
glm::vec2 prev = startPoint; | |
glm::vec2 current; | |
ofPolyline poly; | |
float dt = T/N; | |
float t2; | |
for (size_t i = 0; i < N; i++) { | |
t2 = pow(t, power.get()); | |
d.x = cos(t2) * dt; | |
d.y = sin(t2) * dt; | |
t += inc; | |
current = prev + d; | |
poly.lineTo(current.x * scale, current.y * scale); | |
prev = current; | |
} | |
poly.draw(); | |
gui.draw(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
#include "ofxGui.h" | |
class ofApp : public ofBaseApp{ | |
public: | |
void setup(); | |
void draw(); | |
ofxPanel gui; | |
ofParameter<float> T = {"T", 3.8, 1, 10}; | |
ofParameter<float> scale = {"scale", 260, 1, 10000}; | |
ofParameter<float> inc; | |
ofParameter<float> startT = {"start T", -1.25, -3, 3}; | |
ofParameter<float> power = {"power", 2, 0, 5}; | |
ofParameter<int>N = {"N", 5000, 1, 10000}; | |
ofParameter<glm::vec2> startPoint = {"Start Point", {1,1}, {0,0}, {1,1}}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment