|
|
I have a bitmap image representing a button. I would like to use this same bitmap to represent different states of the button, in particular the default, mouseover and clicked states. Default is the bitmap as it is, but for the other two states I need to make the bitmap slightly lighter and darker. I am doing this by looping through the pixels and manipulating the RGB values.
To make it darker I use this simple formula
crPixel = RGB(
GetRValue(crPixel) * 0.8,
GetGValue(crPixel) * 0.8,
GetBValue(crPixel) * 0.8 );
Multiplying by 0.8 gives the desired effect. But for a lighter bitmap, I try multiplying by 1.2 which doesn't work. The bitmap appears green rather than lighter. Does anybody know the correct formula for adding white to a pixel?
|
|
|
|
|
The issue is that the human eye percieves different colors differently, if you google for a greyscale filter ( or read my C# image processing articles ), you'll get the ratios you need.
I'm not sure if you're using a DIBSECTION, if you aren't, you should.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry, I tend to stay clear of the C# articles. I already had the grayscale filter in place for the disabled button style. As for the DIB's, not yet. Most of the code is in place for it, as soon as it's working, then I will add the tweaks.
|
|
|
|
|
waldermort wrote: Sorry, I tend to stay clear of the C# articles.
*grin* Yeah, if you touch that stuff, the stains are murder to get out.
waldermort wrote: As for the DIB's, not yet. Most of the code is in place for it, as soon as it's working, then I will add the tweaks.
You'll use DIBs ? A DIBSection is a magical DIB that can still be selected into a DC and drawn that way.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
waldermort wrote: But for a lighter bitmap, I try multiplying by 1.2 which doesn't work. The bitmap appears green rather than lighter.
Are you making sure the RGB values don't go over 255?
Mark
|
|
|
|
|
That was probably the problem. I changed the formula so that it alphablends a white pixel, works fine now
crPixel = RGB(
GetRValue(crPixel) * dBlend + (1-dBlend) * 0xff,
GetGValue(crPixel) * dBlend + (1-dBlend) * 0xff,
GetBValue(crPixel) * dBlend + (1-dBlend) * 0xff );
|
|
|
|
|
convert the RGB to HLS ( or the other one ) and just play with the lightness value.
|
|
|
|
|
It is relatively easy to accomplish this if you calculate a HSL (Hue, Saturation and Luminosity) value based on the RGB value. Then modify the L-value, and convert back to RGB. There are tonnes of algorithms on the web for doing this. The only drawback is that it is quite slow, since all the algorithms I've seen so far, use floating point numbers for HSL values.
In any case, it's not equivalent to applying a linear factor on each RGB color component. Been there, done that. It works well on some color nuances, but will look like crap most of the time.
--
For External Use Only
|
|
|
|
|
Thanks for the info, but in the case of my app it's a little of an overkill. I just need a very simple way to extend on a default image in the case a user did not specify one.
|
|
|
|
|
Just make sure you look at all the processed bitmaps before you commit. You may be surprised at the result in some cases (I was!)
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
// Simulation of the Dynamics of a 2-Link Pan-Tilt Robotic Manipulator
/* This programme calculates the Velocity, Acceleration and the angles of inclination
of the two links of the Spherical Pointing Motor, which is essentially a Two-Link Robotic
Manipulator*/
//#include <basis.h>
//#include <assert.h>
//#include <string.h>
//#include <iostream.h>
//#include <iomanip.h>
//#include <fstream.h>
// Precompiler Directives
#include <math.h>
#include <stdlib.h>
/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/
// Constants Declaration
#define n (int) 2
#define m1 (float) 0.05
#define m2 (float) 0.03
#define r1 (float) 0.04
#define r2 (float) 0.06
#define ra (float) 0.04
#define rb (float) 0.06
#define l (float) 0.05
#define d (float) 0.02
#define acc_due_gravity (float) 9.81
#define h (double) 0.01;
// The Classes - Four in all.
class AngVel1 // For the first equation dQ1/dt
{
public:
AngVel1(); // Default Constructor
AngVel1(double om1); // The second and main constructor
double fn1 (double om1);
double RK1 (double y); // prototype for Runge-Kutta equation
private:
double InitialValue1;
};
// Function Definitions
double AngVel1 :: fn1 (double om1)
{
return om1;
}
double AngVel1 :: RK1(double y)
{
double k1,k2,k3,k4;
k1 = h*fn1(y);
k2 = h*fn1(y+(k1/2.0));
k3 = h*fn1(y+(k2/2.0));
k4 = h*fn1(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
};
I am having this error (error C2100: illegal indirection) from lines 73,74,75 and 76 which are the four lines before the last line of code. Please, why am i getting this and how can I get it resolved?
Thanks for your answer.
SKG!
skg
|
|
|
|
|
first, change your #define to const float/int/ ( or better const double )
second, your #define h ends with a ; is that on purpose ?
|
|
|
|
|
// Simulation of the Dynamics of a 2-Link Pan-Tilt Robotic Manipulator
/* This programme calculates the Velocity, Acceleration and the angles of inclination
of the two links of the Spherical Pointing Motor, which is essentially a Two-Link Robotic
Manipulator*/
//#include <basis.h>
//#include <assert.h>
//#include <string.h>
//#include <iostream.h>
//#include <iomanip.h>
//#include <fstream.h>
// Precompiler Directives
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/
// Constants Declaration
#define n (int) 2
#define m1 (float) 0.05
#define m2 (float) 0.03
#define r1 (float) 0.04
#define r2 (float) 0.06
#define ra (float) 0.04
#define rb (float) 0.06
#define l (float) 0.05
#define d (float) 0.02
#define acc_due_gravity (float) 9.81
#define h (double) 0.01
// The Classes - Four in all.
class AngVel1 // For the first equation dQ1/dt
{
public:
AngVel1(); // Default Constructor
AngVel1(double om1); // The second and main constructor
double fn1 (double om1);
double RK1 (double y); // prototype for Runge-Kutta equation
private:
double InitialValue1;
};
// Function Definitions
double AngVel1 :: fn1 (double om1)
{
return om1;
}
double AngVel1 :: RK1(double y)
{
double k1,k2,k3,k4;
k1 = h*fn1(y);
k2 = h*fn1(y+(k1/2.0));
k3 = h*fn1(y+(k2/2.0));
k4 = h*fn1(y+k3);
return y+(k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
};
void main()
{
int i;
double init=1.0;
double temp;
FILE *fp;
fp = fopen("data.txt", "w");
temp = RK1(init);
printf("%4.4f \n", temp);
//fprintf(fp, "%4.5f \n", temp);
for(i=1;i<50;i++){
temp = RK1(temp);
printf("%4.4f \n", temp);
// fprintf(fp, "%4.5f \n", temp);
}
fclose(fp);
}
Thanks for your mail. I have corrected it and it work. Now, i've written the code further but I got this error ('RK1' : undeclared identifier ). How can this be resolved.
Also, do i need a constructor?
Thanks.
Regards,
SKG.
skg
|
|
|
|
|
geez ... C++ 101
I will not directly answer this.
Where is RK1 declarer ? and how do you access it ?
|
|
|
|
|
Thanks for your mail.
Unfortunately, i'm new to C++ programming and again, I jumped from beginner to advanced with this code that i'm writing. I used to program in Java.
If it were to be Java, I know that i'm supposed to write something like
RK1 = new RK1
but I don't know how to do this stuffs in C++.
Please, tell me what to do.
I actually have four equations to code but I decide (following my supervisor's advice) to start with one. Then, i'll add the second class, later the third class and lastly, the fourth.
Once again, thank you.
Regards,
Olagoke.
skg
|
|
|
|
|
sahoong wrote: Please, tell me what to do.
Zac has already done that.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/
// Constants Declaration and initialization 42
const int n = 2;
const double m1 = 0.05;
const double m2 = 0.03;
const double h1 = 0.05;
const double h2 = 0.04;
const double r1 = 0.04;
const double r2 = 0.06;
const double ra = 0.04;
const double rb = 0.06;
const double l = 0.05;
const double d = 0.02;
const double g = 9.81;
const double h = 0.01;
//#define n (int) 2
//#define m1 (float) 0.05
//#define m2 (float) 0.03
//#define h1 (float) 0.03
//#define h2 (float) 0.04
//#define r1 (float) 0.04
//#define r2 (float) 0.06
//#define ra (float) 0.04
//#define rb (float) 0.06
//#define l (float) 0.05
//#define d (float) 0.02
//#define g (float) 9.81
//#define h (double) 0.01 70
// The Classes - Four in all.
class AngVel1 // For the first equation dQ1/dt = w1 (om1)
{
public:
double fn1 (double om1);
double RK1 (double v); // prototype for Runge-Kutta equation
private:
double InitialValue1;
};
// Function Definitions
double AngVel1 :: fn1 (double om1)
{
return om1;
}
double AngVel1 :: RK1(double v)
{
double k1,k2,k3,k4,l1,l2,l3;
k1 = h*fn1(v);
k2 = h*fn1(v + l1/2.0);
k3 = h*fn1(v + l2/2.0);
k4 = h*fn1(v + l3);
return v + (k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
};// End of Class AngVel1 101
class AngAccln1 // For the second equation, dw1/dt
{
public:
double fn2 (double t, double om1, double om2);
double RK2 (double x, double v, double p);
private:
double InitialValue3;
};
// Function Definition for Angular Acceleration
double AngAccln1 :: fn2 (double t, double om1, double om2)
{
double tau1, tetha1, tetha2;
tau1 = 0.1;
tetha1 = 0.5;
tetha2 = 06;
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om2*sin(tetha2)*cos(tetha2) - m2*g*d*cos(tetha1)*cos(tetha2))/
(m1(ra*ra + rb*rb)/4 + m1*h1*h1/3 + m2*r2*r2(1+sin(tetha2)*sin(tetha2))/4 + m2*h2*h2*cos(tetha2)*cos(tetha2)/3 + m2*d*d*cos(tetha2)*cos(tetha2));
}
double AngAccln1 :: RK2 (double x, double v, double p)
{
double l1,l2,l3,l4,k1,k2,k3;
l1 = h*fn2(x, v, p);
l2 = h*fn2(x + h/2.0, v + l1/2.0, p + k1/2.0);
l3 = h*fn2(x + h/2.0, v + l1/2.0, p + k2/2.0);
l4 = h*fn2(x + h, v + l3, p + k3);
return p + (l1/6.0)+(l2/3.0)+(l3/3.0)+(l4/6.0);
}; // End of Class AngAccln1 138
class AngVel2 // For the third equation dQ2/dt = w2 (om2)
{
public:
double fn3 (double om2);
double RK3 (double v); // prototype for Runge-Kutta equation
private:
double InitialValue2;
};
// Function Definitions 154
double AngVel2 :: fn3 (double om2)
{
return om2;
}
double AngVel2 :: RK3(double v)
{
double k1,k2,k3,k4,l1,l2,l3;
k1 = h*fn3(v);
k2 = h*fn3(v + l1/2.0);
k3 = h*fn3(v + l2/2.0);
k4 = h*fn3(v + l3);
return v + (k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}; // End of class AngVel2
class AngAccln2 // For the second equation dw2/dQ 175
{
public:
double fn4 (double t, double om1);
double RK4 (double x, double p);
private:
double InitialValue4;
};
// Function Definition for Angular Acceleration of Link2
double AngAccln2 :: fn4 (double t, double om1)
{
double tau2, tetha1, tetha2;
tau2 = 0.1;
tetha1 = 0.5;
tetha2 = 0.6;
return (tau2 + m2(r2*r2/4 - h2*h2/3 - d*d)*om1*om1*sin(tetha2)*cos(tetha2) - m2*g*d*sin(tetha1)*sin(tetha2))/
m2(r2*r2/4 + h2*h2/3 + d*d);
}
double AngAccln2 :: RK4 (double x, double p)
{
double l1,l2,l3,l4,k1,k2,k3;
l1=h*fn4(x, p);
l2=h*fn4(x + h/2.0, p + k1/2.0);
l3=h*fn4(x + h/2.0, p + k1/2.0);
l4=h*fn4(x + h, p + k3);
return p + (l1/6.0)+(l2/3.0)+(l3/3.0)+(l4/6.0);
}; // End of Class AngAccln2
void main()
{
//RungeKutta rk = RungeKutta(0, 10, 0, 0.1);
// Open a file to save the results in
//ofstream of("rk_test.csv");
int i;
double init=1.0;
double temp1;
double temp2;
FILE *fp;
fp = fopen("data.txt", "w");
AngVel1 angvel;
angvel.RK1(init);
AngVel2 angvel2;
angvel2.RK3(init);
temp1 = angvel.RK1(init);
temp2 = angvel2.RK3(init);
printf("%4.4f \n", temp1);
printf("%4.4f \n", temp2);
//fprintf(fp, "%4.5f \n", temp);
for(i=1;i<50;i++){
temp1 = angvel.RK1(temp1);
temp2 = angvel2.RK3(temp2);
printf("%4.4f \n", temp1);
printf("%4.4f \n", temp2);
// fprintf(fp, "%4.5f \n", temp);
}
fclose(fp);
}
Dear Sac,
I am having these errors
C:\work\CPPCOACH\fintryy.cpp(124) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(125) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(125) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(191) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(192) : error C2064: term does not evaluate to a function
on the following lines of code
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om2*sin(tetha2)*cos(tetha2) - m2*g*d*cos(tetha1)*cos(tetha2))/
(m1(ra*ra + rb*rb)/4 + m1*h1*h1/3 + m2*r2*r2(1+sin(tetha2)*sin(tetha2))/4 + m2*h2*h2*cos(tetha2)*cos(tetha2)/3 + m2*d*d*cos(tetha2)*cos(tetha2));
and
return (tau2 + m2(r2*r2/4 - h2*h2/3 - d*d)*om1*om1*sin(tetha2)*cos(tetha2) - m2*g*d*sin(tetha1)*sin(tetha2))/
m2(r2*r2/4 + h2*h2/3 + d*d);
Thanks for your time.
Regards,
SKG!
skg
|
|
|
|
|
You posted this same code three separate times. Why? Post it once and reference all others to it.
sahoong wrote: return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om2*sin(tetha2)*cos(tetha2) - m2*g*d*cos(tetha1)*cos(tetha2))/
(m1(ra*ra + rb*rb)/4 + m1*h1*h1/3 + m2*r2*r2(1+sin(tetha2)*sin(tetha2))/4 + m2*h2*h2*cos(tetha2)*cos(tetha2)/3 + m2*d*d*cos(tetha2)*cos(tetha2));
Have you considered breaking this up into more manageable statements? If so, you'd see that the parenthesis are not paired up. When using floating-point constants, it helps to use denote them as such (e.g., 2.0*m2, r2/4.0).
All that aside, I'm not seeing the benefit of using classes just yet. So far, calling a bunch of functions is all that's necessary.
Your code is mixing float and double . Why?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
sahoong wrote: I used to program in Java.
If it were to be Java, I know that i'm supposed to write something like
RK1 = new RK1
Okay, knowing that ... forget everything you thought you knew about programming (especially everything Java-related) and start from scratch. If you had learned C++ first, Java would be a piece of cake ... but going the other way is much more difficult since you've picked up some bad habits along the way already ...
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
/*
n = Number of Links = 2
m1 = Mass of the First Link (The Annulus)
m2 = Mass of the Second Link
r1 = Inner Radius of Link 1 (The Annulus)
r2 = Outer Radius of Link 1 (The Annulus)
ra = Outer Radius of the Annulus
rb = Inner Radius of the Annulus
l = Half the Lenght of Link 1
d = Displacement from the Centre of Mass
g = Acceleration due to gravity = 9.81
t = time in seconds
*/
// Constants Declaration and initialization 42
const int n = 2;
const double m1 = 0.05;
const double m2 = 0.03;
const double h1 = 0.05;
const double h2 = 0.04;
const double r1 = 0.04;
const double r2 = 0.06;
const double ra = 0.04;
const double rb = 0.06;
const double l = 0.05;
const double d = 0.02;
const double g = 9.81;
const double h = 0.01;
//#define n (int) 2
//#define m1 (float) 0.05
//#define m2 (float) 0.03
//#define h1 (float) 0.03
//#define h2 (float) 0.04
//#define r1 (float) 0.04
//#define r2 (float) 0.06
//#define ra (float) 0.04
//#define rb (float) 0.06
//#define l (float) 0.05
//#define d (float) 0.02
//#define g (float) 9.81
//#define h (double) 0.01 70
// The Classes - Four in all.
class AngVel1 // For the first equation dQ1/dt = w1 (om1)
{
public:
double fn1 (double om1);
double RK1 (double v); // prototype for Runge-Kutta equation
private:
double InitialValue1;
};
// Function Definitions
double AngVel1 :: fn1 (double om1)
{
return om1;
}
double AngVel1 :: RK1(double v)
{
double k1,k2,k3,k4,l1,l2,l3;
k1 = h*fn1(v);
k2 = h*fn1(v + l1/2.0);
k3 = h*fn1(v + l2/2.0);
k4 = h*fn1(v + l3);
return v + (k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
};// End of Class AngVel1 101
class AngAccln1 // For the second equation, dw1/dt
{
public:
double fn2 (double t, double om1, double om2);
double RK2 (double x, double v, double p);
private:
double InitialValue3;
};
// Function Definition for Angular Acceleration
double AngAccln1 :: fn2 (double t, double om1, double om2)
{
double tau1, tetha1, tetha2;
tau1 = 0.1;
tetha1 = 0.5;
tetha2 = 06;
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om2*sin(tetha2)*cos(tetha2) - m2*g*d*cos(tetha1)*cos(tetha2))/
(m1(ra*ra + rb*rb)/4 + m1*h1*h1/3 + m2*r2*r2(1+sin(tetha2)*sin(tetha2))/4 + m2*h2*h2*cos(tetha2)*cos(tetha2)/3 + m2*d*d*cos(tetha2)*cos(tetha2));
}
double AngAccln1 :: RK2 (double x, double v, double p)
{
double l1,l2,l3,l4,k1,k2,k3;
l1 = h*fn2(x, v, p);
l2 = h*fn2(x + h/2.0, v + l1/2.0, p + k1/2.0);
l3 = h*fn2(x + h/2.0, v + l1/2.0, p + k2/2.0);
l4 = h*fn2(x + h, v + l3, p + k3);
return p + (l1/6.0)+(l2/3.0)+(l3/3.0)+(l4/6.0);
}; // End of Class AngAccln1 138
class AngVel2 // For the third equation dQ2/dt = w2 (om2)
{
public:
double fn3 (double om2);
double RK3 (double v); // prototype for Runge-Kutta equation
private:
double InitialValue2;
};
// Function Definitions 154
double AngVel2 :: fn3 (double om2)
{
return om2;
}
double AngVel2 :: RK3(double v)
{
double k1,k2,k3,k4,l1,l2,l3;
k1 = h*fn3(v);
k2 = h*fn3(v + l1/2.0);
k3 = h*fn3(v + l2/2.0);
k4 = h*fn3(v + l3);
return v + (k1/6.0)+(k2/3.0)+(k3/3.0)+(k4/6.0);
}; // End of class AngVel2
class AngAccln2 // For the second equation dw2/dQ 175
{
public:
double fn4 (double t, double om1);
double RK4 (double x, double p);
private:
double InitialValue4;
};
// Function Definition for Angular Acceleration of Link2
double AngAccln2 :: fn4 (double t, double om1)
{
double tau2, tetha1, tetha2;
tau2 = 0.1;
tetha1 = 0.5;
tetha2 = 0.6;
return (tau2 + m2(r2*r2/4 - h2*h2/3 - d*d)*om1*om1*sin(tetha2)*cos(tetha2) - m2*g*d*sin(tetha1)*sin(tetha2))/
m2(r2*r2/4 + h2*h2/3 + d*d);
}
double AngAccln2 :: RK4 (double x, double p)
{
double l1,l2,l3,l4,k1,k2,k3;
l1=h*fn4(x, p);
l2=h*fn4(x + h/2.0, p + k1/2.0);
l3=h*fn4(x + h/2.0, p + k1/2.0);
l4=h*fn4(x + h, p + k3);
return p + (l1/6.0)+(l2/3.0)+(l3/3.0)+(l4/6.0);
}; // End of Class AngAccln2
void main()
{
//RungeKutta rk = RungeKutta(0, 10, 0, 0.1);
// Open a file to save the results in
//ofstream of("rk_test.csv");
int i;
double init=1.0;
double temp1;
double temp2;
FILE *fp;
fp = fopen("data.txt", "w");
AngVel1 angvel;
angvel.RK1(init);
AngVel2 angvel2;
angvel2.RK3(init);
temp1 = angvel.RK1(init);
temp2 = angvel2.RK3(init);
printf("%4.4f \n", temp1);
printf("%4.4f \n", temp2);
//fprintf(fp, "%4.5f \n", temp);
for(i=1;i<50;i++){
temp1 = angvel.RK1(temp1);
temp2 = angvel2.RK3(temp2);
printf("%4.4f \n", temp1);
printf("%4.4f \n", temp2);
// fprintf(fp, "%4.5f \n", temp);
}
fclose(fp);
}
Dear Sac,
I am having these errors
C:\work\CPPCOACH\fintryy.cpp(124) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(125) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(125) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(191) : error C2064: term does not evaluate to a function
C:\work\CPPCOACH\fintryy.cpp(192) : error C2064: term does not evaluate to a function
on the following lines of code
return (tau1 - 2*m2(r2*r2/4 -h2*h2/3 -d*d)*om1*om2*sin(tetha2)*cos(tetha2) - m2*g*d*cos(tetha1)*cos(tetha2))/
(m1(ra*ra + rb*rb)/4 + m1*h1*h1/3 + m2*r2*r2(1+sin(tetha2)*sin(tetha2))/4 + m2*h2*h2*cos(tetha2)*cos(tetha2)/3 + m2*d*d*cos(tetha2)*cos(tetha2));
and
return (tau2 + m2(r2*r2/4 - h2*h2/3 - d*d)*om1*om1*sin(tetha2)*cos(tetha2) - m2*g*d*sin(tetha1)*sin(tetha2))/
m2(r2*r2/4 + h2*h2/3 + d*d);
Thanks for your time.
Regards,
SKG!
skg
|
|
|
|
|
To debug it, break those return lines down into smaller parts. Having a 3 line long return statement is bad form anyway.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
sahoong wrote: i've written the code further but I got this error ('RK1' : undeclared identifier ).
RK1 is a member function of the class AngVel1. You need to either declare it as static and call it via AngVel1::RK1() or create an object of type AngVel1 and call it using the dot notation:
AngVel1 angvel;
angvel.RK1();
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks but I still get the same error plus this one ('RK1' : function does not take 0 parameters).
How can I declared it as static and making the call.
Regards,
Olagoke.
skg
|
|
|
|
|
I didn't add the parameters (just used ()'s to indicate a function call).
You need to read an intro to C++ book since these questions show that you are a beginner (not bashing you, just letting you know that you will save yourself some time in the long run).
To declare something as static, you add <cdoe>static to its declaration.
static void func();
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|