|
You are defining the rectangle via offsets from center , that is
P0={-x1,-y2}, P1{-x1, y1}, P2={x2,y1}, P3={x2,-y2}
hence, if you wan't rotate with angle phi around the center , than you should compute:
Pr = { x * cos(phi) + y * sin(phi), -x * sin(phi) + y * cos(phi)}
i.e.:
P0R= { -x1 * cos(phi) -y2*sin(phi), x1 * sin(phi) - y2 * cos(phi)}
P1R =...
P2R =...
P3R =...
and then connect the center+PiR points the way you did before.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: P0R= { -x1 * cos(phi) -y2*sin(phi), x1 * sin(phi) - y2 * cos(phi)}
I am confused with it???
Now suppose my values are:
x1 = 330,x2 = 330,y1=330,y2=330
Origin(center.x,cebter.y) = Origin(525,454);
I have to do the get the new x1,x2,y1,y2 before calling MoveToEx and LineTo
Am i right??
i.e
Pr = { x * cos(phi) + y * sin(phi), -x * sin(phi) + y * cos(phi)}
for each x1,x2,y1,y2.
Then call the function
MoveToEx(pCellInfo->hDC,center.x-x1,center.y-y2,NULL);
LineTo(pCellInfo->hDC,center.x-x1,center.y+y1);
LineTo(pCellInfo->hDC,center.x+x2,center.y+y1);
LineTo(pCellInfo->hDC,center.x+x2,center.y-y2);
LineTo(pCellInfo->hDC,center.x-x1,center.y-y2);
Thanks
Raj
|
|
|
|
|
Something like this
double phi = atan(1.0) * 2/3; int x[4];
int y[4];
x[0] = -x1 * cos(phi) - y2 * sin(phi);
y[0] = x1 * sin(phi) - y2 * cos(phi);
x[1] = -x1 * cos(phi) + y1 * sin(phi);
y[1] = x1 * sin(phi) + y1 * cos(phi);
x[2] = x2 * cos(phi) + y1 * sin(phi);
y[2] = -x2 * sin(phi) + y1 * cos(phi);
x[3] = x2 * cos(phi) - y2 * sin(phi);
y[3] = -x2 * sin(phi) - y2 * cos(phi);
for (int i=0; i<4; i++)
{
x[i] += center.x;
y[i] += center.y;
}
MoveToEx(pCellInfo->hDC,x[3],y[3],NULL);
for (int i=0; i<4; i++)
{
LineTo(pCellInfo->hDC, x[i],y[i]);
}
I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot ,its working fine.
Thanks
Raj
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The code looks correct but I find it to be slightly offensive to me sensibilities.
I'm just kidding. I usually make a function or method when I see a sequence of code repeated more than twice. Something like this is generic enough that I definitely would.
Of course, it's not your job to put this is into a function. That is an exercise for the reader.
|
|
|
|
|
|
When you asked this same question[^] yesterday, part of my reply said:
Look at the actual values you are passing to MoveToEx and LineTo.
Until you do that, I'm not interested in helping any more, and I don't think too many others will be either.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
MoveToEx(pCellInfo->hDC,center.x-x1,center.y-y2,NULL);
LineTo(pCellInfo->hDC,center.x-x1,center.y+y1);
I hope you got it,what i am trying to do.
If i am doing wrong,please let me know,
Thanks for your reply
Raj
|
|
|
|
|
When I said "look at the actual values", I didn't mean the expressions, I meant the actual values. In other words, either add some code to print out the values when you call the function or put a breakpoint on the call and inspect the values in your debugger. Then you should be able to figure out what is wrong and work back to where your problem is.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Thank u peter for your reply.Its working fine now
Raj
|
|
|
|
|
Hi,
Can any body having sysinternals
ProcessExplorer source code
|
|
|
|
|
Source code for SysInternals tools are not published.
It was initially a long time ago but not anymore.
|
|
|
|
|
In addition to answer from Superman, you can find source code for similar tools here in CodeProject.
Have a look at this[^] tool.
|
|
|
|
|
Hi thanks
I have seen that but i want
CPU Usage history graph.
Where i can get the same time of graph?
|
|
|
|
|
Check out this[^] CodeProject article.
It contains a Graph control and the demo application uses this control in order to show CPU usage history.
|
|
|
|
|
|
You're welcome!
|
|
|
|
|
I am writing an application that requests a file path from a user so that the application can process supported files in that directory. It is a console application. I would like to know how I can validate the path entered by the user to make sure that the path exists. I am programming in the C language. Please help.
|
|
|
|
|
|
Thanks Niklas, I believe this function will do, but it seem to be a Windows specific function. Do we have any way around in the ANSI C standard? If there isn't I will use the function you showed me, it's just that I want to keep the use of Windows functions at minimum in this application.
|
|
|
|
|
Maybe _stat() from <sys/stat.h> checking if the st_mode member of the _stat struct is _S_ISDIR. I don't know how much standard that is though.
|
|
|
|
|
I'm reading Dennis Ritchie's 'C programming language 2nd ed' and the part that I thought might be a solution is what you've directed me. Thanks very much.
|
|
|
|
|
Which file paths are valid or invalid is determined by the operating system, not the programming language. What is valid for Windows may not be valid for others such as Unix, and vice versa.
If portability of your code is of prime importance, your best bet IMO would be to actually try and use the path, say by attempting to create a file in the given directory path.
When I create portable code, I define my own little virtual OS and have an OS.h file which has different sections for each of the platforms (operating system and compiler tools) I support; it is full of defines from my virtual OS to the actual one.
|
|
|
|
|
Being a bit academic, you are not always able to create a file in a directory, but for other reasons.
Edit: Think I need some sleep.
|
|
|
|
|