Archive

Posts Tagged ‘use’

Moments – Turning Forces

March 16, 2009 6 comments

Moments are often called turning forces. They are the product of the distance a force is acting from the point being considered and the component of the force acting perpendicular to the direction.

The most common example of moments used in on a see saw. Here there a two levers, each side of the see saw, acting from the central pivot. if a person sits on the see saw there is a moment about the pivot because of there weight. While the seesaw is still horizontal this moment is the product of their weight (mass times gravity) and the distance they are still from the pivot because the distance a long the see saw to the pivot is perpendicular to their weight.

Like forces if something is in equilibrium, velocity isn’t changing (usually but not always at rest), the moments have to be balanced. Because moments are turning forces this means that all the moments acting clockwise have to equal all the moments acting anti clockwise. This means that if two people are sitting on the seesaw provided the product of their weight and distance is the same the seesaw wont turn, even if one person is much heavier than the other. For example if a heavy person sits close to the centre they can be balanced by a light person sitting further away.

Just to note – moments don’t have to be calculated about a pivot or turning point, they can be found about any point, so we cud take them about one of the people or the end of the seesaw. IF you do this though, remember that the pivot is providing an upward force on the seesaw that is equal to its mass plus that of the two people times gravity. This sort of method can often be useful in more complex systems as by taking moments about a point then we can ignore all forces acting through it (as their distance is 0) and simplify our equations.

However we can also calculate the moments caused by forces that aren’t perpendicular to their distance, for example the moment cause by the person on the seesaw when it is titled or on the ground. Here we have to find the component of the force that is in the direction that is perpendicular to the distance, by resolving using sin and cos.

This is done by multiplying the product either by the sin of the angle between force and the direction of the distance between the force and pivot or the cos of the angle between them force and the direction perpendicular to the distance.

for example if the seesaw is tilted by 30 degrees from the horizontal we can have to multiply by

cos(30)=sin(60) =√3 /2

By David Woodford,

If you have any questions please leave them in comments below or email me at david.woodford.4@googlemail.com

Advertisements

Matrix Calculator, C++ Program by David Woodford

April 23, 2008 5 comments

Ive been learning c++ and doing matrices in maths as well so I’ve decided to combine to the two in a simple command based program. The basic idea of the program is that it can quickly multiply matrices together and perform reflection and rotation transformations on them. Below is a download of the program and the source code. In the following weeks ill also make some tutorials on doing matrices by hand (click here for my multiplication lesson). Later im hoping to add some more features to it like finding the inverse matrix and the determinate

Download now !!!!!!!!!!

So how to use the program, well first of all type help. This will then display a list of the commands and what they do. When using it type your command, eg mlt, on its own, the program will then ask you to enter which is the first matrix and the second matrix in the multiplication. Every value should have the enter key pressed after its typed.

The program allows up to 10 matrices to be stored in memory plus the answer to the last calculation. They are stored in an array and are given numerical values. The first one you define, using dim, is matrix 0 the second is matrix 1 etc. The answer to the last calculation is matrix 10. When the program ask you which matrix you want to use it is asking you to enter this value for the matrix

Using the let command allows you to give one matrix the value of another. The first matrix number you enter is the one that the values being assigned to, the second is the value thats being assigned. This command is useful if you want to store the answer, after youve done the next calculation, to do this type let, when prompted type matrix that you want to be given the value of the answer and then give the value 10 for the value its being assigned.

Below is the code, i wrote it in visual c++ 2008, for the program. You may have to make changes if you using a diffrent complier to the includes at the top.

Enjoy using, but only to check, note all angles are in degrees recomplie if you want radians.


// matrix.cpp : main project file.

#include “stdafx.h”
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

class mat
{
public:
double mata[20][3];
int lgth;
void dimmat()
{
cout << “enter length of matrix” << endl;
cin >> lgth;
//    cout << “” << endl;

for(int n=0;n<3;n++)
{
cout << “enter values for row” << n << ” , each followed by ‘enter’:” << endl;
for(int m=0;m<lgth;m++)
{
cin >> mata[n][m];
}
}
}

void display()
{
int rcount = 0;
int ccount = 0;

while(rcount < 3)
{
while(ccount < lgth)
{
//cout << “matrix:”<<endl;
cout << mata[rcount][ccount] << ” , “;

ccount++;
}
cout << ‘\n’;
ccount=0;
rcount++;
}
}

/*void rotate()
{
mat mat2;
mat2.dimmat();
mat mat3;
mat3 = mult(this, mat2);
}*/
};

mat mult(mat A, mat B)
{
cout << “multiply started” << endl;

//char pause;

mat ans;
ans.lgth=B.lgth;

int rcount = 0;
int ccount = 0;
int c2 = 0;

while(rcount < 3)
{
//cout << “row: ” << rcount << ” started” << endl;
while(ccount < A.lgth)
{
//cout << “collum: ” << ccount << “started” << endl;

ans.mata[rcount][ccount] = 0;
while(c2 < 3)
{
ans.mata[rcount][ccount] = ans.mata[rcount][ccount] + (A.mata[rcount][c2] * B.mata[c2][ccount]);
c2++;
}
//cout << “value is: ” << ans.mata[rcount][ccount] << endl;
//cin >> pause;
c2=0;
ccount++;
}
ccount=0;
rcount++;
}

int smelly;
ans.display();
return ans;
}

mat rotate(mat A, int angle)
{
mat T;
T.lgth = 3;

mat matans;

//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(theta);
T.mata[0][1] = 0 – sin(theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(theta);
T.mata[1][1] = cos(theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

mat reflect(mat A, int angle)
{
mat matans;
mat T;
T.lgth = 3;
//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(2 * theta);
T.mata[0][1] = sin(2 * theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(2*theta);
T.mata[1][1] = 0 – cos(2*theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

void input()
{
string dim = “dim”;

string com;
int end = 0;

mat matans;
int matcount = 0;
mat mats[11];
while(end == 0)
{
cout << “enter command>”;
getline(cin, com);

if(dim == com)
{
cout << “matrix” << matcount <<endl;
mats[matcount].dimmat();
matcount++;
}
if(com == “rot”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = rotate(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “rlt”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = reflect(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “ans”)
{
matans.display();
}
if(com == “mlt”)
{
cout << “first matrix” << endl;
int mat1;
cin >> mat1;
cout << “second matirx” << endl;
int mat2;
cin >> mat2;

matans = mult(mats[mat1], mats[mat2]);
mats[10] = matans;
}
if(com == “dsp”)
{
cout << “which matirx?” << endl;
int matdsp;
cin >> matdsp;
mats[matdsp].display();
}
if(com == “let”)
{
cout << “which matirx?” << endl;
int mat1;
cin >> mat1;
int mat2;
cout <<“eaqual to (10 is answer matrix)” << endl;
cin >> mat2;
mats[mat1] = mats[mat2];
}
if(com == “help”)
{
cout <<“Davids Woodfords matrix calculator” << endl;
cout << “takes the following commands” << endl;
cout <<” ‘dim’    ::  allows you to dfine a matrix”<< endl;
cout <<” ‘rot’    :: roates a matrix through an agnle” << endl;
cout <<” ‘rlt’    :: reflects a matrix through the line y=tan(a) where a is given” << endl;
cout <<” ‘ans’    :: displays the answer to the last calculation” << endl;
cout <<” ‘mlt’    :: lets u multiply 2 matricies together” << endl;
cout <<” ‘dsp’    :: displays a matrix specified”<<endl;
cout <<” ‘let’    :: allows u to assign one matrix the value of another, eg answer”<<endl;
cout<<“===================================================================”<<endl;
cout <<“matricies are sotred in an array of 10, with numerical values starting at 0″<<endl;
cout<<“matrix 10 is the answer matrix”<<endl;
cout<<“any parameters will be asked for wen needed”<<endl;

}
}

}

int main()
{
cout << “Welcome to David Woodfords Matrix calculator” << endl << endl;
cout<<“type ‘help’ for a list of commands” <<endl;
//    mat mata;
//    mata.dimmat();

/*    mat matb;
matb.dimmat();

mat matans;
matans = mult(mata, matb);
//    mata.display();
*/
//rotate(mata, 30);
input();
return 0;
}

Proof of Cosine Rule

February 17, 2008 3 comments

Below is the proof by Pythagoras’s theorem of the cosine rule, a2=b2+c2– 2bccosA.

This assumes you understand Pythagoras’s theorem (visit pythagoras’s theorm to view my lesson on it), how to use basic trigonometry(basic trigonometry lesson). If you want to learn how to use the cosine and sine rule, opposed to just learning the proof) visit by sine and cosine rule page.

The proof is done using the letters of the following triangle

Triganometry Trianlge

and we are trying to prove the cosine rule:

a2=b2+c2– 2bccosA

In triangle CBL
a2 = (c-x)2 + h2
a2 = c2 – 2cx + x2 + h2
h2 = a2 -c 2– x2 + 2cx <<EQN1

in triangle CLA
b2 = h2 + x2
h2 = b2 – x2 <<EQN2

eqn1 – eqn2 :: 0 = a2 – c2 – b2 +2cx
a2 = c 2+ b2 – 2cx <<EQN3

in CLA
cosA = x/b
x = bcosA

in eqn3

a2 = c2 + b2 – 2bccosA

 

 

So there is the proof for the cosine rule using pythagorases therom. If you found that usefull try looking at my other maths lessons

 

Understand the Sine and Cosine Rules

February 13, 2008 11 comments

This assumes you already have a knowledge of basic trigonometry(ir using sin, cos and tan in a right angled triangle, if you don’t click here to read my lesson on these) and aims to teach you how to use the sine and cosine rule.

In basic trigonometry you can only look at a right angled triangle which greatly limits its applications, however with these formula you can calculate sides and angles in any triangle provided you know enough information. They are proved by splitting one triangle in 1/2 so that the dividing line is perpendicular to one of the sides and therefore creating 2 right angled triangle in which the normal rules can be applied.

Sine/Cosine rule triangle

The following use symbols as defined in the above triangle. Note that side a is opposite angle A and b is opposite B etc

Sine Rule

a/sinA = b/sinB = c/sinC

This allows us to find both an angle and a side as we can invert all of the fractions and it remains true. This means if we know the side opposite the angle we want and any other side angle pair we can work out the angle we want, or we can work out a side if we know the angle opposite it and any other side angle pair.

EG)Lets say
a = 10cm
b = 5cm
B = 30o
and we want to find angle A

we know a side angle pair, b and B, and we know the side opposite the angle we want so we can write the sine rule as
sinA / 10 = sinB/b >>note we don’t need to include the c parts as we dont know either c or C
sinA / 10 = sin30/5
sinA = 10sin30/5
sinA = 1
A = sin-11
A = 90o

We can work out any angle or side in a similar way.

Cosine rule
This rule allows us to find an angle if we know all the sides or a side if we know the other 2 and a angle

c² = a² + b² – 2abcosC

To find an angle we can re-arrange it so
C = cos-1((a2 + b2 – c2)/2ab)

Im sure you can put the numbers in yourself as ive show you how it can be written to find either an angle or side so ill leave you to it 🙂 enjoy

If you have any questions, improvements, or suggestions please leave a comment below or email me at woodford_4@hotmail.co.uk. Also visit my site at www.breakingwave.co.nr