Click here to Skip to main content
16,005,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: AfxBeginThread Pin
Member 6562829-Apr-05 3:49
Member 6562829-Apr-05 3:49 
GeneralRe: AfxBeginThread Pin
PJ Arends29-Apr-05 6:20
professionalPJ Arends29-Apr-05 6:20 
QuestionHow do i disable mouse wheel in comboBox (MFC) Pin
Yanshof27-Apr-05 18:11
Yanshof27-Apr-05 18:11 
AnswerRe: How do i disable mouse wheel in comboBox (MFC) Pin
Rage27-Apr-05 22:31
professionalRage27-Apr-05 22:31 
General2d arrays Pin
aaadetos27-Apr-05 17:54
aaadetos27-Apr-05 17:54 
GeneralRe: 2d arrays Pin
Paul M Watt27-Apr-05 18:45
mentorPaul M Watt27-Apr-05 18:45 
GeneralRe: 2d arrays Pin
Anonymous28-Apr-05 4:35
Anonymous28-Apr-05 4:35 
GeneralRe: 2d arrays Pin
aaadetos28-Apr-05 7:52
aaadetos28-Apr-05 7:52 
New Problem: Now I'm doing the multiplication, where I'm trying to multiply the arrays in this order:
<br />
lambda_array*dip_array*azim_array*r_array<br />

what am i doing wrong? all my values in the final range array, fr_array are all zero, which shouldn't be the case...
Here's the code.
<br />
// Q2_new.cpp : Defines the entry point for the console application.<br />
//<br />
<br />
#include <math><br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
double theta, phi, t, p;	//azimuth and dip angles respectively<br />
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 />
//---------------------------------------------------------<br />
//Initializing the arrays to zero<br />
//---------------------------------------------------------<br />
	//array that holds the dip angle, phi<br />
	double dip_array [3][3] = {0};	<br />
<br />
	//array that holds the azimuth angle, theta<br />
	double azim_array [3][3] = {0};	<br />
<br />
	//array that holds the anisotropy ratios<br />
	double lambda_array [3][3] = {0};	<br />
<br />
	//array that holds the original range values<br />
	double r_array [3] = {0};<br />
<br />
	//array that holds final range values<br />
	double fr_array [3][3] = {0};	<br />
<br />
<br />
//---------------------------------------------------------<br />
//Code to convert the angles to radians, acceptable in C++<br />
//---------------------------------------------------------<br />
//Dip Angle,p<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 />
//Azimuth Angles, t<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++)//for each row<br />
  {<br />
	  for (int j=0; j<cols; j++)	//for each column value<br />
		  cout << arg[i][j] << " ";<br />
	  cout << "\n";<br />
  }<br />
}<br />
<br />
void printarray2(double arg[]) <br />
{<br />
  for (int i=0; i<rows; i++)//for each row<br />
  {<br />
	  //for (int j=0; j<3; j++)	//for each column value<br />
		  cout << arg[i] << " ";<br />
	  cout << "\n";<br />
  }<br />
}<br />
<br />
	//code for multiplication of the dip and azim matrices<br />
	void mult(double fr_array[3][3])<br />
	{<br />
		for(int i=0;i<rows;i++)	//for each row<br />
		{<br />
			for(int j=0;j<cols;j++)	//for each column<br />
			{<br />
				for(int k=0;k<cols;k++)	//for each column<br />
				{<br />
					for(int l=0;l<cols;l++)	//for each column<br />
					{<br />
					//	fr_array [i][j] += dip_array [i][k]*azim_array [k][j];<br />
						fr_array [i][j] += lambda_array [i][l]*dip_array [l][k]*azim_array[k][j];<br />
						fr_array [i][j] += fr_array[i][j]*r_array[i];<br />
					}<br />
				}<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 />
	//-----------------------------------------------------------<br />
	//Initializing the matrices<br />
	//-----------------------------------------------------------<br />
	//array that holds the dip angle, phi<br />
	double dip_array [3][3] = {{d11,0,d13},{0,1,0},{d31,0,d33}};	<br />
<br />
	//array that holds the azimuth angle, theta<br />
	double azim_array [3][3] = {{a11,a12,0},{a21,a22,0},{0,0,1}};	<br />
<br />
	//array that holds the anisotropy ratios<br />
	double lambda_array [3][3] = {{lambda1,0,0},{0,1,0},{0,0,lambda2}};	<br />
<br />
	//array that holds the original range values<br />
	double r_array [3] = {4,8,3.94};<br />
<br />
<br />
	//----------------------------------------------------------------<br />
<br />
	//code to check that the arrays are properly initialized in the matrices for any theta,phi<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 />
<br />
	mult(fr_array);<br />
	cout<<"\nThe final range array is:\n";<br />
	printarray(fr_array);<br />
<br />
<br />
<br />
	return 0;<br />
}


You can use 60 degrees for theta and phi, for check, since cos(60) = 0.5, sin(60) = 0.866....
QuestionWin32 Console Application project ? Pin
Anonymous27-Apr-05 17:36
Anonymous27-Apr-05 17:36 
AnswerRe: Win32 Console Application project ? Pin
Yanshof27-Apr-05 18:24
Yanshof27-Apr-05 18:24 
GeneralRe: Win32 Console Application project ? Pin
Anonymous28-Apr-05 0:11
Anonymous28-Apr-05 0:11 
GeneralRe: Win32 Console Application project ? Pin
Anonymous28-Apr-05 0:15
Anonymous28-Apr-05 0:15 
GeneralRe: Win32 Console Application project ? Pin
ThatsAlok28-Apr-05 1:08
ThatsAlok28-Apr-05 1:08 
Questionwindow hook uninstalled? Pin
outoolcoe27-Apr-05 17:27
outoolcoe27-Apr-05 17:27 
GeneralNeed Your Help!!!! Pin
Jack.Fu27-Apr-05 16:31
Jack.Fu27-Apr-05 16:31 
GeneralRe: Need Your Help!!!! Pin
mkuhac27-Apr-05 17:17
mkuhac27-Apr-05 17:17 
GeneralRe: Need Your Help!!!! Pin
Jack.Fu27-Apr-05 17:36
Jack.Fu27-Apr-05 17:36 
GeneralRe: Need Your Help!!!! Pin
Rage27-Apr-05 22:36
professionalRage27-Apr-05 22:36 
GeneralRe: Need Your Help!!!! Pin
ThatsAlok27-Apr-05 23:07
ThatsAlok27-Apr-05 23:07 
Generalimport TStringGrid component to MFC Pin
27-Apr-05 15:51
suss27-Apr-05 15:51 
QuestionCan Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
macauit27-Apr-05 14:49
macauit27-Apr-05 14:49 
AnswerRe: Can Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
Ryan Binns27-Apr-05 19:15
Ryan Binns27-Apr-05 19:15 
AnswerRe: Can Use VirtualAllocEx( ) to Get Memory from Other Process? Pin
stolid_rock27-Apr-05 19:21
stolid_rock27-Apr-05 19:21 
GeneralCannot find file bug Pin
Jorgen E.27-Apr-05 13:21
Jorgen E.27-Apr-05 13:21 
Generalinitializing pointers / handles Pin
mkuhac27-Apr-05 12:52
mkuhac27-Apr-05 12:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.