• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

A little math geekiness on a boring workday...

Here is the first of 2 files (test3.h). I'll post test3.cpp in another post:

class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};

class CMainWindow : public CFrameWnd
{
public:
CMainWindow();
protected:
const static int scalar = 240;
double XPolarFn(double);
double YPolarFn(double);
const static long Off = 1;
const static long On = 0;
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
 
And here is test3.cpp:

#include <stdafx.h>
#include <math.h>
#include "test3.h"
CMyApp myApp;

BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMainWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWindow::CMainWindow()
{
Create(NULL, "TEST");
}

double CMainWindow::XPolarFn(double angle)
{
double value;
value = sin(angle);
value *= scalar;
return(value);
}

double CMainWindow::YPolarFn(double angle)
{
double value;
value = sin(angle) * sin(.9 * angle);
value *= scalar;
return(value);
}

void CMainWindow:😱nPaint()
{
CClientDC dc (this);
CRect rect;
double angle, angle_increment, centerX, centerY;

angle_increment = 0.01;
GetClientRect(&amp;rect);
centerX = rect.Width() / 2;
centerY = rect.Height() / 2;

for(angle = 0; angle <= 360; angle += angle_increment)
dc.SetPixel((int)(XPolarFn(angle) * cos(angle) + centerX), (int)(YPolarFn(angle) * sin(angle) + centerY), 0);
}
 
Back
Top