fix midpoint

This commit is contained in:
2022-03-03 21:47:35 +01:00
parent 3e342396fe
commit 8a9d0286ef
3 changed files with 39 additions and 35 deletions

View File

@@ -1,8 +1,8 @@
#include <cmath>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
#include <cmath>
using namespace std::chrono_literals;
@@ -12,17 +12,8 @@ using namespace std::chrono_literals;
int main()
{
double const pi = 3.14159;
constexpr double pi = 3.14159;
std::cout << "pi: " << pi << " " << 3.14159f << std::endl;
std::cout << "pi / 180;" << pi / 180.f << std::endl;
for(int i = 0; i < 360; i += 45)
{
std::cout << "(i): " << i << std::endl;
std::cout << "rad: " << (float)i * pi / 180.f << std::endl;
}
return 0;
frame::display::EPD_7in5_V2 display{};
@@ -34,28 +25,20 @@ int main()
frame::Vector const center = (display.getSize() / 2);
frame::Vector v = {10, 12};
std::cout << "Main: " << v << std::endl;
target.DrawPixel({10, 10}, frame::BLACK);
target.DrawLine(v, {100, 12}, frame::BLACK);
target.DrawLine({10, 12}, {100, 12}, frame::BLACK);
for(int i = 0; i < 360; i += 45)
for(int i = 0; i < 360; i += 15)
{
auto end = center;
double const cos_ = i * 0.01745329;
std::cout << i << " cos: " << cos_ << std::endl;
double x = std::cos(cos_);
double y = std::sin(i * 0.01745329);
x *= 50.f;
y *= 50.f;
std::cout << x << " " << (int)x << " " << y << std::endl;
double const x = std::cos(i * pi / 180.f) * 200.f;
double const y = std::sin(i * pi / 180.f) * 200.f;
end.x += (int)x;
end.y += (int)y;
std::cout << end << std::endl;
target.DrawLine(center, end);
}