Skip to content

Instantly share code, notes, and snippets.

@juanfal
Last active November 7, 2018 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanfal/fb15ff4fead7621813aa99c2f76c0152 to your computer and use it in GitHub Desktop.
Save juanfal/fb15ff4fead7621813aa99c2f76c0152 to your computer and use it in GitHub Desktop.
Plot the implicit curve 9x2 + 4y2 = 3600
// 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