|
I can't figure why the following matrix multiplication isn't working. Can someone please help me?
<br />
<br />
#include <math><br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
double theta, phi, t, p;
double lambda1 = 0.5;<br />
double lambda2 = 2;<br />
double a11,a12,a21,a22,d11,d13,d31,d33;<br />
const double pi = 3.142857;<br />
const int rows = 3;<br />
const int cols = 3;<br />
<br />
void mult(double *fr_array2);<br />
<br />
<br />
double dip_array [3][3] = {0}; <br />
<br />
double azim_array [3][3] = {0}; <br />
<br />
double lambda_array [3][3] = {0}; <br />
<br />
double r_array [3] = {0};<br />
<br />
double fr_array [3][3] = {0}; <br />
<br />
double fr_array2 [3] = {0}; <br />
<br />
<br />
<br />
double a(double p)<br />
{<br />
d11 = cos((p*pi)/180);<br />
return d11;<br />
}<br />
<br />
double b(double p)<br />
{<br />
d13 = -1*sin((p*pi)/180);<br />
return d13;<br />
}<br />
<br />
double c(double p)<br />
{<br />
d31 = sin((p*pi)/180);<br />
return d31;<br />
}<br />
<br />
double d(double p)<br />
{<br />
d33 = cos((p*pi)/180);<br />
return d33;<br />
}<br />
<br />
<br />
double e(double t)<br />
{<br />
a11 = sin((t*pi)/180);<br />
return a11;<br />
}<br />
<br />
double f(double t)<br />
{<br />
a12 = cos((t*pi)/180);<br />
return a12;<br />
}<br />
<br />
double g(double t)<br />
{<br />
a21 = -1*cos((t*pi)/180);<br />
return a21;<br />
}<br />
<br />
double h(double t)<br />
{<br />
a22 = sin((t*pi)/180);<br />
return a22;<br />
}<br />
<br />
<br />
void printarray (double arg[][3]) <br />
{<br />
for (int i=0; i<rows; i++)
{<br />
for (int j=0; j<cols; j++)
cout << arg[i][j] << " ";<br />
cout << "\n";<br />
}<br />
}<br />
<br />
void printarray2(double arg[]) <br />
{<br />
for (int i=0; i<rows; i++)
{<br />
cout << arg[i] << " ";<br />
cout << "\n";<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
<br />
cout<<"ANISOTROPY MODELLING.\n";<br />
cout<<"\nPlease enter a real number between 0 and 360 for the azimuth angle, theta, then press the 'Enter' key.\n\n";<br />
cin>>t;<br />
<br />
cout<<"\nPlease enter a real number between 0 and 360 for the dip angle, phi, then press the 'Enter' key.\n\n";<br />
cin>>p;<br />
<br />
a(p);<br />
b(p);<br />
c(p);<br />
d(p);<br />
e(t);<br />
f(t);<br />
g(t);<br />
h(t);<br />
<br />
double dip_array [3][3] = {{d11,0,d13},{0,1,0},{d31,0,d33}}; <br />
<br />
double azim_array [3][3] = {{a11,a12,0},{a21,a22,0},{0,0,1}}; <br />
<br />
double lambda_array [3][3] = {{lambda1,0,0},{0,1,0},{0,0,lambda2}}; <br />
<br />
double r_array [3] = {4,8,3.94};<br />
<br />
<br />
<br />
cout<<"\nThe dip array is:\n";<br />
printarray(dip_array);<br />
<br />
cout<<"\nThe azimuth array is:\n";<br />
printarray(azim_array);<br />
<br />
cout<<"\nThe anisotropy array is:\n";<br />
printarray(lambda_array);<br />
<br />
cout<<"\nThe original range array is:\n";<br />
printarray2(r_array);<br />
<br />
<br />
mult(fr_array2);<br />
cout<<"\nThe final range array is:\n";<br />
printarray2(fr_array2);<br />
<br />
<br />
<br />
return 0;<br />
}<br />
<br />
void mult(double *fr_array2)<br />
{<br />
for(int j=0;j<cols;j++)
{<br />
for(int i=0;i<rows;i++)
{<br />
fr_array2 [j] += r_array[i]*azim_array[i][j];<br />
}<br />
}<br />
}
For whatever value of theta or phi I enter, the final range array consistently reads '0' which shouldn't be. What am I missing???
|
|
|
|
|
Anybody is having LSB Insertion algorithm? Any code in VC++ for the algorithm?
|
|
|
|
|
That kind of question is not really funny!!!!
Search Google!
Don't try it, just do it!
|
|
|
|
|
Hi...
I am having a problem on coverting Bitmap image to IplImage format.Is there
is any OpenCV function to convert it?Or will u please help me with any other way of Conversion..
with a lots and Lots of Hope
Regards,
Hari
|
|
|
|
|
we need a code to take a poto by using a web cam
|
|
|
|
|
|
hi ,
I am trying to change BackColor of MS CommandButton from Thread. But it is giving me Exception.
code of Thread is :
UINT mainThread(LPVOID param)
{
while(!killThread)
{
if(yes)
{
try
{
yes = FALSE;
dlg->m_jbutn.SetBackColor(0x0000ff00);
//dlg is a ptr to dialog (same as 'this')
}
catch(...)
{
MessageBox(NULL,"Exception","Error",NULL);
}
}
Sleep(500);
}
return 0;
}
/**********************/
m_jbutn.SetBackColor(0x0000ff00);
this line works fine outof Thread. So why it is not working in Thread.
|
|
|
|
|
You can only update a GUI control from the same thread that created it. You'll have to send a message to the thread to tell it to update the button.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
Does anyone know if it is possible to set up DMA to transfer data between two memory locations within my C++ application, so that I would use CPU for other calculations while transferring data with no CPU involvement.
Cheers,
Vitaly
|
|
|
|
|
You can't!
DMA devices are not available to user-mode applications. They are also NEVER used to copy memory simply from one location to another!
They are used to copy memory from physical addresses of buses (e.g. PCI bus) to virtual memory sections allocated by the OS and vice-versa.
Don't try it, just do it!
|
|
|
|
|
Hi.. I posted this difficulty before also .. My application is playing only PCM encoded wave files.. I need to play a file which is compressed and in the CCITT A-Law audio format .. How to uncompress it and play..? OR how to convert a file from A-Law to PCM..
Any suggestions???..
Thank you
pallavi
|
|
|
|
|
Build a DirectShow filter graph and play it.
Read the DirectShow SDK for further information.
Don't try it, just do it!
|
|
|
|
|
I am doing some operation on files. The operation vary for files which are currently in use and which are not. So i wish to know that how to find whether a file is in use or not. I try to open file exclusively but it returns true even if the file is in use by some program.
Thanks.
|
|
|
|
|
Does anyone know a way to determine the launching process of another process that has no parent? ie. was started with system function or cmd /c start
Any help would be greatly appreciated!
|
|
|
|
|
you have to hook CreateProcess for that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
can you be more specific. i am trying to write a program that will retrace respawning spyware back to launching process. the respawned processes have no parent, so how to determine which process launched it.
|
|
|
|
|
|
Thanks Alok! looks like some stuff in there I may be able to use. I am vb/vfp programmer in over his head a little with c++ code, but I am feeling my way through it. Sometimes just need a point in right direction! thanks again
dman
|
|
|
|
|
warning C4786: '__ehhandler$?ExecSQL@CDBHandle@@QAE?AV?$_com_ptr_t@V?$_com_IIID@U_Recordset@@$1?_GUID_00000556_0000_0010_8000_00aa006d2ea4@@3U__s_GUID@@A@@@@V?$_com_ptr_t@V?$_com_IIID@U_Conne
ction@@$1?_GUID_00000550_0000_0010_8000_00aa006d2ea4@@3U__s_GUID@@A@@@@VCString@@@Z' : identifier was truncated to '255' characters in the debug information
what do this warning is talking about?
thanks for any help!
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Is there a Microsoft 'bug' number for the fact that the GDI rectangles functions stop one short of drawing all the way to the right and bottom coordinates?
For example, if the pen width is one, a Rectangle(0, 0, 16, 16) call will only draw to (0,0)-(15,15)
The Windows GDI function calls involving filled rectangles will draw one pixel short on the right edge and the bottom edge of the specified rectangle. This is documented in MSDN for Rectangle and FillRect, but no mention is made for RoundRect, FrameRect, and InvertRect (even though they also exhibit this behavior).
This is a problem for us because we are trying to represent the locations of our objects using ‘logical’ coordinates and ‘logical extents’ (Visual extent of object rather than logical ‘GDI’ location). We are trying to avoid storing the boundaries of objects in terms of ‘screen coordinates’ so that we might better server our customers with panning, zooming, and device resolution independence.
I had also been told this was 'fixed' in GDI+, or can I just assume that GDI+ 'broke' the existing 'functionality'
|
|
|
|
|
Nice rant. Never mind that it made you look look an idiot...
See, when the documentation specifically states that a function works in a particular way, and then it works that way, it's generally not considered to be a bug. For example, here's the doc comment on FillRect.
The FillRect function fills a rectangle by using the specified brush. This function includes the left and top borders, but excludes the right and bottom borders of the rectangle.
So you're bitching because it does what it says it will do? Or did you even bother to read the docs?
|
|
|
|
|
I am quoting myself here:
This is documented in MSDN for Rectangle and FillRect, but no mention is made for RoundRect, FrameRect, and InvertRect (even though they also exhibit this behavior).
I did read the docs. Read the docs for InvertRect. You would be inclined to think it inverted the ENTIRE rectangle, but it does not. Same for RoundRect and FrameRect. No mention of excluding the edges of the rectangles there. I might have to install my April 1994 MSDN to see if Microsoft mentioned it there or not. That is how old the program I am trying to maintain is.
If you are making a graphics application that is very interested in the visual extent of a rectangle, and you have the logical coordinates for it, it causes a lot of tweaks to be required, one place or the other.
|
|
|
|
|
|
Thanks for the great link. I can see that EndPoint-Exclusive is beneficialif you want your rectangles to border each other. We want ours to be able to visually overlap one pixel.
|
|
|
|