-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathellipse.cpp
More file actions
39 lines (32 loc) · 810 Bytes
/
ellipse.cpp
File metadata and controls
39 lines (32 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
#include <numbers>
#include "manifold.hpp"
using namespace Eigen;
using namespace std;
class Ellipse : public Manifold {
public:
double a, b;
Ellipse(double a, double b)
: Manifold(2, 1, 2.5,
VectorXd::Constant(1, 0.0),
VectorXd::Constant(1, 2.0 * numbers::pi)),
a(a), b(b) {}
VectorXd coord(const VectorXd& u) override {
double t = u[0];
VectorXd x(2);
x << a * cos(t), b * sin(t);
return x;
}
MatrixXd pushforward(const VectorXd& u) override {
double t = u[0];
MatrixXd J(2, 1);
J << -a * sin(t), b * cos(t);
return J;
}
};
int main() {
Ellipse e(2.0, 1.0);
auto samples = e.sample(10);
for (const auto &x : samples)
cout << x.transpose() << endl;
}