简体   繁体   English

在 C++ 中计算 3X3 旋转矩阵

[英]Calculating a 3X3 rotational matrix in C++

I'm new to programming and currently I'm taking an intro class with C++ with no programming background aside from HTML.我是编程新手,目前我正在学习 C++ 入门课程,除了 HTML 之外没有任何编程背景。

So my first assignment is to make a program that calculates a 3X3 rotational matrix.所以我的第一个任务是制作一个计算 3X3 旋转矩阵的程序。 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.我仍然不知道 3X3 旋转矩阵是什么。 I understand this should be simple, by testing my abilities of using cin/cout and the use of operators.我明白这应该很简单,通过测试我使用 cin/cout 和使用运算符的能力。

I only know how to use cin/cout basically.我基本上只知道如何使用cin/cout。

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.所以这就是我到目前为止所做的,希望我走在正确的轨道上:导入 iostream、cmath 和 iomanip 库并设置 cout/cin。

The four inputs, a rotation angle in radians, and an x, y, and z value of a vector to rotate around四个输入,以弧度为单位的旋转角度,以及要绕其旋转的向量的 x、y 和 z 值

So I have theta, ux,yz and uz setup in cout |所以我在 cout 中设置了 theta、ux、yz 和 uz | cin like so: cin 像这样:

#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.同样离题,当我通过 SSH 使用 Geany 时,它真的很慢。 Tried it on my windows computer and linux with the same results.在我的 windows 计算机和 linux 上尝试过,结果相同。 Is there a way I can fix that or is that just due to the nature of using a IDE through SSH?有什么方法可以解决这个问题,还是仅仅因为通过 SSH 使用 IDE 的性质?

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应该用这个公式计算https://upload.wikimedia.org/math/f/b/a/fbaee547c3c65ad3d48112502363378a.png so I'm assuming I should put that in the cin part of OutMatrix?所以我假设我应该把它放在 OutMatrix 的 cin 部分?

First off, the last cin >> is an input statement, but you should output the result.首先,最后一个cin >>是一个输入语句,但您应该输出结果。 That's cout << .那是cout <<

Secondly, since you didn't cover arrays yet, it's easiest to just write out all 9 elements individually.其次,由于您还没有涵盖数组,因此最简单的方法是单独写出所有 9 个元素。 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.为了让所有内容都很好地对齐, '\\t'是一个制表符(移到下一列),而'\\n'是一个换行符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM