I'm new to programming and currently I'm taking an intro class with C++ with no programming background aside from HTML.
So my first assignment is to make a program that calculates a 3X3 rotational matrix. Now the problem is, I have no idea how I to start it out. I'm still lost on what a 3X3 rotational matrix is. I understand this should be simple, by testing my abilities of using cin/cout and the use of operators.
I only know how to use cin/cout basically.
The end result should look like this:
So this is what I'm at so far, hopefully I'm on the right track: Imported iostream, cmath, and iomanip libraries and setup the cout/cin's.
The four inputs, a rotation angle in radians, and an x, y, and z value of a vector to rotate around
So I have theta, ux,yz and uz setup in cout | cin like so:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
cout << "Enter Theta:"
cin >> theta;
cout << "Enter ux:"
cin >> ux;
cout << "Enter uy:"
cin >> uy;
cout << "Enter uz:"
cin >> uz;
cout << "OutMatrix:"
cin >>
}
Hopefully once I get this assignment done I'd be able to understand everything a lot better, programming seems really fun if you know the basics. I'm just lost on this assignment though.
Also offtopic, when I use Geany over an SSH it's really laggy. Tried it on my windows computer and linux with the same results. Is there a way I can fix that or is that just due to the nature of using a IDE through SSH?
EDIT: I should have clarified, we haven't gone over arrays yet since this is our first assignment so we're just getting into the basics. It should be calculated with this formula so I'm assuming I should put that in the cin part of OutMatrix?
First off, the last cin >>
is an input statement, but you should output the result. That's cout <<
.
Secondly, since you didn't cover arrays yet, it's easiest to just write out all 9 elements individually. You'll learn more efficient methods later on.
To get everything nicely aligned, '\\t'
is a tab (move to next column) and '\\n'
is a newline.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.