Last active
November 7, 2018 09:27
-
-
Save juanfal/fb15ff4fead7621813aa99c2f76c0152 to your computer and use it in GitHub Desktop.
Plot the implicit curve 9x2 + 4y2 = 3600
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
// elipseImplicita.cpp | |
// juanfc 2016-11-04 | |
// Plot the implicit curve: | |
// 9x2 + 4y2 = 3600 | |
// It approximates as part of the curve, dots in the | |
// range of ALLOWANCE | |
// https://gist.github.com/fb15ff4fead7621813aa99c2f76c0152 | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
const int HEIGHT = 31; // ~ sqrt(3600/9) | |
const int WIDTH = 31; // ~ sqrt(3600/4) | |
const float ALLOWANCE = 110; | |
int main() | |
{ | |
for (int lin = -HEIGHT; lin < HEIGHT; ++lin) { | |
for (int col = -WIDTH; col < WIDTH; ++col) | |
if (fabs(4*lin*lin + 9*col*col - 3600) < ALLOWANCE) | |
cout << '*'; | |
else | |
cout << ' '; | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment