From bd3f70a62f8c2868e20f094a0ad7dd8c977ab853 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Fri, 2 Sep 2016 18:08:53 -0300 Subject: Motor under implementation --- Project/Generator.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Project/Generator.cpp') diff --git a/Project/Generator.cpp b/Project/Generator.cpp index 74adbef..c98e912 100644 --- a/Project/Generator.cpp +++ b/Project/Generator.cpp @@ -1,6 +1,18 @@ #include "Generator.h" -Generator::Generator() {} +Generator::Generator() : Element() +{ + int numPtsSine = 10; + double mx = 15.0; + double my = 10.0; + double pi = 3.14159265359; + + for(int i = 0; i <= numPtsSine; i++) { + double x = (2.0 * pi / double(numPtsSine)) * double(i) - pi; + double y = std::sin(x); + m_sinePts.push_back(wxPoint2DDouble((x / pi) * mx, y * my)); + } +} Generator::~Generator() {} bool Generator::AddParent(Element* parent, wxPoint2DDouble position) { @@ -53,6 +65,13 @@ void Generator::Draw(wxPoint2DDouble translation, double scale) const glColor4d(0.2, 0.2, 0.2, 1.0); DrawCircle(m_position, 25.0, 20); + + // Draw sine. + std::vector sinePts; + for(int i = 0; i < (int)m_sinePts.size(); i++) { + sinePts.push_back(m_sinePts[i] + m_position); + } + DrawLine(sinePts); } } -- cgit