|
i want an algorithm for computing the vector that coming out from the rotation of another a vector given that we have the angle of rotation
please coz i eed it in a project in c++
|
|
|
|
|
Sounds like a simple trig problem to me. Sounds like homework, too.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
You don't seem to learn that when you don't ask specific questions about problems in your code, that almost nobody is willing to help you... A good start would be to just grab your textbook and try to implement to algorithm destcribed there.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
NOOO
DONT MISSUNDERSTAND ME!!!!!
i dont want anyone to write the code for me i want only the law of computing this
THE LAWWWWWWWW
ONLY THAT!!!!
thats what i mean by an algorithm i dont mean the code please dont misunderstand me
thats a question about mathematics
how can i rotate a vector with a given angle of rotation?????????????
|
|
|
|
|
So it's only the theory that you are after? In one of your posts you said that you went through google, yahoo and more to find a solution. If that's true, I wonder why you didn't find this[^]. The answer was on the first page of a google search with the keywords: rotate 3d vector.
You'll find only theory there, but you can implement it very easy. I know it's true, since I already programmed the solution in Java.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
yes i found that but i want to know if the rotation id for only 3d vectors
i mean that this page on google is every thing about rotation
i am sorry i may dont ask specific questions but thats because of my poor english
|
|
|
|
|
I don't know what that's not good, since it is exactly the theory about rotating objects, especially 3D vectors... Believe me, I know it, since I implemented that exact algorithm in Java during one of my classes...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
If you rotate (x,y) by angle r to get (x',y') then
x' = cos(r)*x - sin(r)*y
I'll leave the formula for y' as an exercise.
You can at least do some of your homework yourself
Steve T
|
|
|
|
|
Mr. steve thats not a homework the home work is to do it in c++
so i need to know the law first
thats all
but i want ask some thing this thats for rotation of vector of two dimensions only so if there are also rotation of the vector of n size??????
|
|
|
|
|
This seem very ridiculous to me
If the teacher is only interested in your abilitly
to write the solution in C++ then ask your teacher
for the required formulas.
And if you want to tell us this is not a C++
question then why are you asking in a C++ forum?
You can use Google to find this sort of solution,
and you will learn more by doing so than you will
by having someone spoon-feed you the answers.
Steve T
|
|
|
|
|
no my teacher wont refuse if i asked him for the law but there is a long way between us i have to travel to go him because he is not here now he is travelling abroad & will come to the collegue the next saturday when we will give him the solution on disks
& i asked here in c++ forums bacause i thoght u could help me nothhing more coz u may have the answers & will save time for me
i logged onto many websites like ggogle & yahoo & others but i couldnt found my need so i asked here
and i dont want u to thought badly of me i just a beginner need help in c++ so could u help me in becoming one great programmer in such language coz i realy want to be one like this
i dont want to be a lazy person who needs to be fed the answers with spoon like u said nooooooo absolutely not
if i was like i would have given the whole proplem to any programmer in my country and give him money for programming that for me without any effort
i wouldnt have logged onto ur site to ask u for help
so all i want in this forums is HELP!!
OK have u understood me now
i hope u changed ur mind about me
|
|
|
|
|
#include "stdafx.h"
template<class char_type>
class ccTest
{
public:
struct sub_class_type
{
char_type char_one_;
sub_class_type() : char_one_(0) {}
void external_func(char_type ch);
void internal_func(char_type ch)
{ char_one_ = ch; }
};
void func()
{
sub_class_type sub;
sub.internal_func('a');
sub.external_func('b');
}
};
template<class char_type>
void ccTest<char_type>::sub_class_type
::external_func(char_type ch)
{ char_one_ = ch; }
int main(int argc, char* argv[])
{
ccTest<char> test_var;
test_var.func();
return 0;
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
You are using VC6?
I compiled your code in VC6 and I get error LNK2001
When compile it in VC7 I get error C3206: 'ccTest<char_type>::sub_class_type::external_func' : member functions of nested classes of a template class cannot be defined outside the class
sig test
|
|
|
|
|
Thank you very much!
It looks like VC7 gives much better error messages, so I'll have to leave it internal to the class, blast it.
I'll have to look this up in the C++ specs to find out why. Because you can nest as far as you want in an non-templated class and still define the functions external to the class. A template is just a method used to generate a class; therefor, I would think that the same rules would apply.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
I'll have to look this up in the C++ specs to find out why
From MSDN:
[quote]
This error is generated for code allowed by the C++ language, however, not yet supported by Visual C++.
[/quote]
sig test
|
|
|
|
|
Hi,
can somebody give me a link to a portable (win32, linux)
Socket Library?
yes, I know about the thing they call "google".
boost::socket is not ported to linux (or am I wrong?)
CommonC++ SocketPort have some bugs.
thank you.
|
|
|
|
|
I thought the basic socket library (SOCKET, recv(), select() etc) was available on win32 and linux
|
|
|
|
|
Hi,
How to make the CAPS is on tooltip appear when focus is set to password textbox with CAPS on?
Please advise.
Regards,
Jap.
|
|
|
|
|
Use GetKeyState function along with CToolTipCtrl[^] class.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
I want to write a C++ template class Nvector that enables arrays with negative subscripts to be defined. The class should be usable in the following code fragment:
>
> Nvector<double> a; // instantiate double array class
> a.resize(-10, 10); // allocate array from locations -10 to 10
> for(int i=-10 ; i<=10 ; ++i)
> a[i] = exp(-k*(T-k*i)); // fill array
>
Also, the class should be written so that array set/access is optimally efficient. Show through the template specification that multidimensional arrays can also be defined.
I coded up like this:
// array template
#include <iostream.h>
#include "Nvector.h"
#include "math.h"
int main()
{
int k = 3;
NvectorDouble<double> a[21];
a.resize(-10, 10);
for (int i =-1; i<= 10; i++)
a[i] = exp( -k*(10-k*i) );
return 0;
}
// the template class included in the head file Nvector.h
#include <iostream.h>
template <class t="">
class NvectorDouble
{
int lowIndex, highIndex; // the low and high index allowed
double *data; // pointer to the vectored data
public:
NvectorDouble (); // default constructor
~NvectorDouble (); // class destructor
bool resize(int newLowIndex, int newHighIndex); // allocates memory for data
double &operator[] (int index); // overload the [] operator
};
template<class t="">
bool NvectorDouble<t>::resize(int newLowIndex, int newHighIndex){
lowIndex = newLowIndex;
highIndex = newHighIndex;
double data[highIndex-lowIndex];
}
But I couldn't get it to run correctly, please be aware that I am a beginer in C++, could you please help me this?
|
|
|
|
|
What error are you getting? Compile time or run time? Also, make sure you check the "Do not treat <'s as HTML tags" checkbox before posting template code.
Regards
Senthil
_____________________________
<font face="Verdana" size=1><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href = "http://www.codeproject.com/script/articles/list_articles.asp?userid=492196">My Articles</a> | <a href = "http://geocities.com/win_macro">WinMacro</a></font>
|
|
|
|
|
Dear Senthil,
Thanks for your reply.
Post again !!
I have problem with the operator overloading i think.
I want to write a C++ template class Nvector that enables arrays with negative subscripts to be defined. The class should be usable in the following code fragment:
>
> Nvector a; // instantiate double array class
> a.resize(-10, 10); // allocate array from locations -10 to 10
> for(int i=-10 ; i<=10 ; ++i)
> a[i] = exp(-k*(T-k*i)); // fill array
>
Also, the class should be written so that array set/access is optimally efficient. Show through the template specification that multidimensional arrays can also be defined.
I coded up like this:
// array template
#include
#include "Nvector.h"
#include "math.h"
int main()
{
int k = 3;
NvectorDouble a[21];
a.resize(-10, 10);
for (int i =-1; i<= 10; i++)
a[i] = exp( -k*(10-k*i) );
return 0;
}
// the template class included in the head file Nvector.h
#include
template
class NvectorDouble
{
int lowIndex, highIndex; // the low and high index allowed
double *data; // pointer to the vectored data
public:
NvectorDouble (); // default constructor
~NvectorDouble (); // class destructor
bool resize(int newLowIndex, int newHighIndex); // allocates memory for data
double &operator[] (int index); // overload the [] operator
};
template
bool NvectorDouble::resize(int newLowIndex, int newHighIndex){
lowIndex = newLowIndex;
highIndex = newHighIndex;
double data[highIndex-lowIndex];
}
But I couldn't get it to run correctly, please be aware that I am a beginer in C++, could you please help me this?
|
|
|
|
|
No one can/will help if you do not post the exact error.
John
|
|
|
|
|
Could you please run it on your system? I dont know what's the exact problem.
Many thanks.
|
|
|
|