楕円軌道
https://scrapbox.io/files/64d7317596732a001cb26328.png
code:楕円軌道.cpp
# include <Siv3D.hpp>
Vec2 elliptical(const Ellipse& ellipse, double theta) {
Vec2 pos = OffsetCircular({ 0,0 }, ellipse.a, theta);
pos.y *= ellipse.b / ellipse.a;
pos += ellipse.center;
return pos;
}
void Main()
{
Texture texture{ U"example/siv3d-kun.png" };
const Ellipse ellipse{ Scene::Center(),200,50 };
constexpr int32 N = 12;
constexpr double time = 3;
while (System::Update())
{
for (auto i : step(N)) {
double t = Periodic::Sawtooth0_1(time, Scene::Time() + i * time / N);
double theta = t * 360_deg + 90_deg;
if (0.5 <= t) {
elliptical(ellipse, theta).asCircle(10).draw(HSV{ 360 * i / (double)N });
}
}
texture.drawAt(Scene::Center());
for (auto i : step(N)) {
double t = Periodic::Sawtooth0_1(time, Scene::Time() + i * time / N);
double theta = t * 360_deg + 90_deg;
if (t < 0.5) {
elliptical(ellipse, theta).asCircle(10).draw(HSV{ 360 * i / (double)N });
}
}
}
}