|
Hi, just use the pointer to the buffer.
Make an destination buffer float* dest[6*p.n] and give it to the function like
you did with the source buffer.
void ScaleVector(float *src, float *dst, float deltaT){
for (int i = 0; i < p.n; i++){
float vx = *(src++);
float vy = *(src++);
float vz = *(src++);
float ax = *(src++);
float ay = *(src++);
float az = *(src++);
dst[i] = vx * deltaT + 0.5 * ax * deltaT * deltaT;
dst[i*6 + 1] = vy * deltaT + 0.5 * ay * deltaT * deltaT;
dst[i*6 + 2] = vz * deltaT + 0.5 * az * deltaT * deltaT;
dst[i*6 + 3] = ax * deltaT;
dst[i*6 + 4] = ay * deltaT;
dst[i*6 + 5]= az * deltaT;
}
}
But like V2.0 said stl-vectors are a better solution.
codito ergo sum
|
|
|
|
|
In addition to the above suggestion of using vectors etc, you could also use the old methods. Note that I haven't tested it.
//Also make sure that the src parameter is now large enough.
void ScaleVector(float *src, float deltaT)
{
for (int i = 0; i < p.n; i++)
{
float vx = src[i]; // velocity on x axis
float vy = src[i+1]; // y axis
float vz = src[i+2]; // z axis
float ax = src[i+3]; // acceleration on x axis
float ay = src[i+4]; // y axis
float az = src[i+5]; // z axis
src[i] = vx * deltaT + 0.5 * ax * deltaT * deltaT; // calculate the displacement at x axis
src[i+1] = vy * deltaT + 0.5 * ay * deltaT * deltaT; // y axis
src[i+2] = vz * deltaT + 0.5 * az * deltaT * deltaT; // z axis
src[i+3] = ax * deltaT; // added speed at x
src[i+4] = ay * deltaT; // y
src[i+5] = az * deltaT; // z
}
}
this is this.
|
|
|
|
|
I need to launch a GUI application from another application
that is running as a Window Service.
To do that I use the CreateProcess method. This is the code:
<br />
PROCESS_INFORMATION l_ProcessInfo;<br />
STARTUPINFO l_StartupInfo;<br />
<br />
ZeroMemory(&l_StartupInfo, sizeof(STARTUPINFO));<br />
<br />
l_StartupInfo.cb = sizeof(STARTUPINFO);<br />
l_StartupInfo.dwFlags = STARTF_USESHOWWINDOW;<br />
l_StartupInfo.wShowWindow = SW_SHOWMAXIMIZED;<br />
<br />
CreateProcess(NULL, <br />
l_cstrFileToLaunch.GetBuffer(0), <br />
NULL, <br />
NULL, <br />
FALSE,<br />
DETACHED_PROCESS,<br />
NULL,<br />
NULL,<br />
&l_StartupInfo,<br />
&l_ProcessInfo))
The problem is the following:
the GUI application is launched (CreateProcess returns nonzero and I can
see the new process running by task manager) but its windows is not shown
and I can't see its hinstance in the Windows Command bar.
Where is the problem ?
Can someone help me ?
thanks a lot !!!
|
|
|
|
|
Hi ilgale,
your code worked,
whats problem(I run NotePad) and this work
|
|
|
|
|
That code runs ok if executed by an application that runs normally...
but not if executed by an application that runs as a Window
Service.
I've registered an application as a Window Service and I've
started it by the Service Control Manager. In that case the
CreateProcess doesn't let the "child" application to show its window.
|
|
|
|
|
Will something like this help:
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
[YourProcessId],TRUE);
SetForegroundWindow();
SetFocus();
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
[YourProcessId],FALSE);
~RaGE();
|
|
|
|
|
Thanks a lot !!!
but.. what's the HWND object that I have to pass to
SetForegroundWindow and SetFocus functions ?
If I've well understood I've to run that code into the
Service that uses the CreateProcess but.. I need an HWND object to pass to that functions....
|
|
|
|
|
ilgale wrote: If I've well understood I've to run that code into the
Service that uses the CreateProcess
Yes sorry, I had to go away from my desk, so I fired up the post.
This is a snippet used to bring a dialog on the top of the Z-order, i thought it coudl work in your case. I do not exactely know how a service works, but I assume it is a normal Win application started differently. So I believe you must be able to get a HWND with GetSafeHwnd() from within the service.
~RaGE();
|
|
|
|
|
The problem is that the service in not a Win application,
it is a simple C++ program with a main, including MFC
functions. So I don't have an HWND object
I think the problem is in STARTUPINFO object settings...
|
|
|
|
|
I think the problem is that the service is not interactive. You should make it interactive if it is not already.
this is this.
|
|
|
|
|
|
|
Hello
I wanna create a Visual C++ program that encrypt a message and plit the ancrypted message into certain parts,and then the message will be recostructed by a certain amount of parts of the encrypted message.
|
|
|
|
|
For the encryption part, simply type encryption in the combo box on the up left of this page (under code project) and you'll find enough article to help you get a start at it.
For the splitting part, I would try and do a search about zip libraries: they used to provide file splitting algorithms.
~RaGE();
|
|
|
|
|
I am currently trying to complile programs which use the vmr9 direct show filter. Unfortunatly i get an error in MS Vis Studio .NET 2003 saying that it cannot locate the file vmr9.h .
I have installed the DirectX SDK (October 2005) and i cant find the files anywhere for download across the net.
Any ideas ?
Cheers
|
|
|
|
|
vmr9.h is in platform sdk.
-Saurabh
|
|
|
|
|
I am using Visual c++ 6.0
Would you like to give me a Class that make DateTimePicker Flat ?
Urgent
I learn my self
|
|
|
|
|
A bitmap file is in size of 200x100 (pixels).
Now CDC is in MM_LOENGLISH MapMode, If I use ::SetDIBitsToDevice() to print whole bitmap, printed bitmap is very small.
Question:
if Bitmap size is in LOGIC points, the printed image should be in size 2x1 (inches) - but actual printed bitmap is much smaller than that.
so:
is Bitmap size LP or DP?
hint:
DPtoLP changes (200,100) to (33,-17).
A nice hyper tool for optimizing your Microsoft html-help contents.
A best image tool for Windows C++ programmers, don't miss it!.
Includeh10
-- modified at 7:01 Tuesday 28th March, 2006
|
|
|
|
|
hi,
I have set the image for a subitem as follows
LVITEM litem;
litem.mask = LVIF_IMAGE;
litem.iSubItem = 1;
litem.iItem = 0;
litem.iImage = 0;
m_List.SetItem( &litem );
but when I try to call the GetItem to get the image associated with a subitem, its not working(it is working if the subitem is 0). I have set the LVS_EX_SUBITEMIMAGES style of the list control. What else should I do..
Please help me
nave
|
|
|
|
|
maybe it is some helpful to you
IMAGEINFO ImageInfo;
CImageList* m_pImageList = GetImageList(LVSIL_NORMAL);
m_pImageList->GetImageInfo(nImage, &ImageInfo);
|
|
|
|
|
Thanks,
But What i want to know is the image number associated with a subitem in listctrl. I think the above function won't help me in that..
nave
|
|
|
|
|
Naveen R ,
I have this problem(But I have derived CListCtrl and I use this way in the NM_CUSTOMDRAW)
anyway I think you can use
int nImage=GetNextItem(-1,LVNI_SELECTED);
|
|
|
|
|
I don't think that you can get the index for a sub-item image, since the iImage member of LVITEM structure is specifically described as the index of the item's image, and not the index of the sub-item's image.
Maybe you must manually store the sub-item's image index in the lParam of the item and retrieve it from there.
Best,
Mike
|
|
|
|
|
Hi there,
I have a program written in C++. I need to convert it to Matlab. I have use mex to run my C++ program, but I do not understand what is mxarray? Do I need to change my C++ program to fit the mxarray?
Zaara
|
|
|
|
|