Visual C++ :: MFC Coordinate System - Drawing Of Angles?
Oct 11, 2013
I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:
Code:
double CompassDegreesToRadians(double compassDegrees) {
return((PI / 2.0f) - (compassDegrees * PI / 180.0f));
}
// Make pen
CPen penRed;
penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));
// Test Angles
[Code] .....
Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:
Code:
180 -y
|
|
-x 270---------------- 90 +x
|
|
0 +y
This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):
Code:
0 +y
|
|
-x 270---------------- 90 +x
|
|
180 -y
View 4 Replies
ADVERTISEMENT
Apr 15, 2012
I have 2 points in a cartesian coordinate system, where the first point is always (0,0). Given the second point and a heading in degrees, how would I write an algorithm to determine if the 2nd point is traveling in the general direction of (0,0) ?
For example:
Point a (0,0)
Point b (10,0)
Point b heading = 270 degrees
This would be true this 270 degrees points right and point b is 10 units right of point a. I would probably also want this is be fuzzy somewhat, in that anything from say + or - 30 degrees would also be true, or something like this.
View 6 Replies
View Related
Mar 24, 2013
I have a linear buffer coordinate, i am to print onto a screen coordinate.
Say maxy = 20, maxx = 10, bufferx = 20, y, x,
Buffer coordinates to screen coordinates:
Algorithm: So for each maxx'th of bufferx, y will +1 and x will reset.
Mathematical: y = int bufferx / maxx,
const double averageIncr = int (maxx+1/maxx) - double (maxx+1/maxx);
So the amount of averageIncr in (int bufferx / maxx - float bufferx / maxx)
is the screen x coordinate. Then
(int bufferx / maxx - float bufferx / maxx) / averageIncr = x
Screen coordinates to buffer coordinates:
bufferx, y = 21, x = 10, maxy = 20, maxx = 10,
y * x would be the case if bufferx <= max screen coordinate.
There is no max bufferx.
How to find the transition from screen coordinates to buffer coordinates? Also, if the algorithm within a for loop, or that the mathematical way would be slower or not? I rarely touch floating point stuff.
View 3 Replies
View Related
Oct 5, 2012
I wrote a simple clock that shows the time over bitmap as follows:
Code:
void CMyClock::OnPaint()
{
CRect rect;
GetClientRect(&rect);
[Code]....
Now I got rid off the white border but everytime I draw a text it write on top of the previous text so after few seconds everything is a mess and the time is no longer readable.
View 5 Replies
View Related
Jan 23, 2015
I am trying to draw a rubber band rectangle. I have got a following code from a site but its giving an error:
Code:
class CSampleView: Public CView{
...
public:
CrectTracker m_tracker;//Changed to CRectTracker
...
};
Secondly, in the constructor to initialize the object CRectTracker document class:
CSampleDoc :: CSampleDOC () {
// Initialize tracker position, size and style.
m_tracker.m_rect.SetRect (0, 0, 10, 10);
m_tracker.m_nStyle = CRectTracker :: resizeInside |
CRectTracker :: dottedLine;
}
The error is:
error C2065: 'm_tracker' : undeclared identifier
How to get rid of this error??
View 4 Replies
View Related
Jul 6, 2014
I am trying to figure out how to create a program that will draw a triangle using *'s with a base the has a user-inputted number of *'s like so:
*
***
*****
It needs to take a user inputted number and draw a pyramid like the above pyramid with the number of *'s in the base matching the user inputted number (i.e., user enters 10, so the triangle has 10 *'s in the base). I figured it would be best to first create a loop to draw out the correct number of *'s before trying to create another loop to draw out the correct number of spaces, to properly align the *'s into a triangle shape.
int width = 0;
int height = 0;
int i = 0;
int leafWidth = 0;
[Code] .....
View 7 Replies
View Related
Jan 22, 2014
I want to show a list of graphical items in 1 or 2 columns (user selected). I will draw the items (owner-draw). I tried many hours today to find a solution with clistctrl. Is it possible to make it with clistctrl?
View 14 Replies
View Related
Jan 19, 2015
The question says: Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().
OK, I wrote below code. It is in its primary stages and has not been completed yet.
Code:
#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;
//---------------------------------
class Dynamic_clock : public Window {
[Code] .....
I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.
[URL] ....
View 14 Replies
View Related
Feb 3, 2014
I am facing a programming logic problem. I want to draw radius sized lines from centre of circle to the circle boundary.
My code is:
int x1, y1, x2, y2, i, r, old_xc,old_yc, x,y;
int xc, yc;
x1=170;
y1=300;
x2=70;
y2=400;
pDC->Ellipse(x1,y1,x2,y2);
[Code] .....
The lines are touching the circle boudary at only start while the rest of lines are smaller and the shape is a triangle instead of a pie slice.
View 8 Replies
View Related
Oct 22, 2014
I know the user installation must involve some registry manipulations and some other trickery. But the ActiveX way seems to be more modular.
Is it worthwhile to separate the charting modules from the exe and make an activex dll for this purpose?
View 5 Replies
View Related
Dec 22, 2013
I have a quick question. I need a way to represent orientation in degrees. I made a class which automatically changes negative angles into positive ones (adds 360 until >0) and makes sure they are under 360 (subtracts 360 until <360).
Now I realized I also need a class to represent angular movement, which must be in the range ]-360;360[
I don't think custom types with the unsigned keyword is a thing, but I'm just looking for a better way to do this then making two classes. Or would you just create a class which inherits from angle and overloads a few methods?
Or I could just use floats to represent rotation, because testing if an object does more than 1 turn per second isn't really required.
View 9 Replies
View Related
May 8, 2014
Given an array of angles A = [0 30 60 90 120 150 180 210 240 270 300 330 360]
Write a program that will generate the data set of angles automatically and provide three columns; sin(angle), cos(angle), tan(angle). Make this program as compact and readable as possible.
View 2 Replies
View Related
May 2, 2013
So using InitiateSystemShutdownEx causes a Win32 machine to go log off go to the shutdown screen and just sit there displaying shutting down with the working indicator just spinning. I left the machine sitting there for an hour and it never shut down. This works fine on all the Win7 x64 machines we are using but the one 32 bit Win7 machine has this problem and it occurs no matter what parameters I pass.
Code:
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return false ;
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);
[code]....
This is working fine on Win7 x64 but not on the one Win7 32 system we have and like I said it starts the shutdown process just never finishes.
View 14 Replies
View Related
Feb 7, 2013
I want to run Unhidden.exe in drive N: and send char to that program. I use function like this
Code:
system("N:/Unhidden.exe");
It can open Unhidden.exe but it run in visual studio 2010Projects . I try to use command N: and Unhidden.exe in cmd it can run in drive N: . So I try to use function like this
system("N:");
system("Unhidden.exe");
but it not found Unhidden.exe . How to use 2 command in sytem() function ?
View 4 Replies
View Related
Apr 4, 2014
I am struggling to find a replacement of NtQuerySystemInformation call for 64-bit Windows OS, like on Windows Server 2008 (64-bit). Need getting overall CPU utilization (average) over all CPU cores?
Code:
#include "StdAfx.h"
#include "CpuMuninNodePlugin.h"
#define SystemBasicInformation 0
#define SystemPerformanceInformation 2
#define SystemTimeInformation 3
[Code] ....
View 6 Replies
View Related
Feb 18, 2015
I have a character at a co-ordinate, say (3,4) for example, and I need to get him to (10,15). I would like him to move one block every tick or half a second, so that you can see him moving towards his destination. How to achieve this?
View 3 Replies
View Related
Jan 21, 2013
I am getting "driver could not be loaded due to system error 8" error while connecting to SQL Server 2005 from VC++. Its also throwing out of memory error. Basically i am developing and ISAPI dll. I use the following code to connect to DB.
CDatabase DBConnection;
if(! DBConnection.IsOpen()) {
DBConnection.OpenEx("Driver={SQL Server};Server=10.120.110.30;Database=Test;Trusted_Connection=yes;", CDatabase:penReadOnly | CDatabase::noOdbcDialog);
[Code] .....
for CDatabaseConnection, i can see 2 different method to open the connection, OpenEx and Open. Whats the difference between OpenEx and Open?
View 7 Replies
View Related
Feb 11, 2013
I wish to add the item 'Website' to an MFC Dialog app System Menu so that it can activate the following method:
Code:
void CMyDlg::OnWebpage()
{
ShellExecute( NULL, NULL, _T("[URL]..."), NULL, NULL, 0 );
}// OnWebpage()
I have tried this:
Code:
#define IDM_WEBSITE (WM_USER + 101)
//..
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
pSysMenu->AppendMenuW(MF_STRING, IDM_WEBSITE, _T("Website"));
}
[Code]...
The code compiles without error but and the 'website' item appears on the System Menu but it doesnt do anything.
I've inspected the following but don't really understand how it works and it seems to me there should be a simpler way to accomplish my end.
Modifying the System Menu By John Simmons 26 Jan 2007 [URL]....
View 8 Replies
View Related
Apr 29, 2014
I have a very strange problem with the system() function (on XP).
I have the following code:
Code:
char *text1 = ""A SpaceAction.bat" fred";
char *text2 = ""A SpaceAction.bat" "fred"";
int main(int argc, char *argv[]) {
printf("%s
", text1);
[Code] .....
When I run it where "A Space" is a directory with a space in the name, this is the result:
Code:
"A SpaceAction.bat" fred
F:Test>echo Testing
Testing
"A SpaceAction.bat" "fred"
'A' is not recognized as an internal or external command, operable program or batch file.
It seems that the double quotes round an argument make the parsing of the command fail.
View 1 Replies
View Related
Dec 19, 2012
I need make a CBitmap or a streamdata from a System.Windows.Controls::Image(rendered out put)in a SDI mfc application (supporting clr). Here is my codes:
Code:
using namespace System;
using namespace System::IO;
using namespace System::Collections::Generic;
using namespace System::Windows;
using namespace System::Windows::Controls;
[Code] .....
By this codes i can read datastream from bitmapSource but in this way somthing goes wrong in most of GIF animations. After debug i found out i need 3 more things too decode a gif animation - (x,y) position and size of each frame and disposal method for each one - finally i just found a way to draw tru images on a form window by this codes:
Code:
System::Windows::Window^ mainWindow;
mainWindow = gcnew System::Windows::Window();
mainWindow->Title = "GIF Imaging Sample";
//ScrollViewer^ mySV = gcnew ScrollViewer();
array<System::Byte>^ pixels = gcnew array<System::Byte>(bitmapSource->PixelHeight * Stride);
[Code] ...
When i change
Code: bitmapSource = decoder->Frames[0];
to
Code: bitmapSource = decoder->Frames[01];
frame[1] has drawn perfectly on window(i think some how Image class takes care about - (x,y) position and size of each frame and disposal method for each one ),so im wonder if how can i make a CBitmap or a data stream from System.Windows.Controls::Image class to use in mfc app.
View 2 Replies
View Related
Jun 23, 2014
So, in a program I'm making, I have an idea, that I can print the character background first, then print another layer on top of the background. Can I do that? But I need to be able to place a single character at a certain position, what function does that?
View 5 Replies
View Related
Dec 8, 2012
I have two pieces of code:
Code:
#include <cmath>;
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
[Code] ....
I am using the gnu glpk library to calculate a linear program for my matrices. Why I get the error message exit code 3 which apparently means "The system cannot find the path specified"?
View 12 Replies
View Related
May 23, 2013
How can i convert pixel to [-1..1]coordinate in opengl? Which function? I want to write a program that is work with
glutmousefunc(),
When I click on the screen a ball is appear on it where clicked. but mouse work with pixel and circle work with coordinate between -1 and 1 ....
View 4 Replies
View Related
May 3, 2014
After searching on stackoverflow I got this
POINT p;
for (int i = 0;; ++i) {
HWND hwnd = GetConsoleWindow();
system("cls");
if (ScreenToClient(hwnd, &p)) {
//p.x and p.y are now relative to hwnd's client area
} cout << p.x << " " << p.y;
Sleep(200);
}
I'm looking for a function that gives current mouse position(x and y) in that particular console window. I've tried above code but it is not working.
View 5 Replies
View Related
Dec 15, 2012
I have a problem: solve the system of equations by the Gauss-Jordan methods with pthreads. I have a big matrix A (for example 2000x2000), so i must solve Ax = b. Before I devide matrix to number of threads and each thread must work only with his peace of matrix.
Code:
#include <iostream>
#include "synchronize.h"
#include <pthread.h>
using namespace std;
typedef struct _ARGS {
int thread_count;
int thread_number;
[Code] .....
I write it on Ubuntu, and when I compile [g++ main.cpp -o main -lpthread -lm] the it works good(for example, if in 1 thread I get time_of_working = 10 sec, on 2 threads time_of_working = 5.4, i.e. about 2 times faster ), if I compile like this [g++ main.cpp -o main -lpthread -lm -O3] it is only 1.2-1.3 times faster.
View 1 Replies
View Related
Feb 8, 2015
Cam is a pointer to a structure and viewpoint is a vector located within the struct. I am trying to read in from a file the coordinates for the vector. I have also tried &cam->view_point->x as well as &cam.view_point.x and it tells me that I am requesting something not in a struct
Code: count= fscanf(in,"%d %d %d", &cam->view_point.x, &cam->view_point.y,&cam->view_point.z);
View 14 Replies
View Related