-
Notifications
You must be signed in to change notification settings - Fork 5
Homework 1 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Homework 1 #13
Conversation
Complited task 1. Vector.
|
|
||
| class Vectors | ||
| { | ||
| public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оставьте только методы публичными, данные сделайте приватными
| { | ||
| public: | ||
|
|
||
| double x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Назовите поля класса так, чтобы было понятно, что это поля и отличать их от других переменных. Добавьте префикс m_ к имени каждого поля.
| double x; | ||
| double y; | ||
| double z; | ||
| /*Vectors() : x(0), y(0), z(0)// конструктор а |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Раскомментарьте конструкторы.
| std::cout << y << std::endl; | ||
| std::cout << z << std::endl; | ||
| };*/ | ||
| /*Vectors() // на всякий случай |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это зачем ? У вас еще уже один конструктор без параметров.
| std::cout << y << std::endl; | ||
| std::cout << z << std::endl; | ||
| };*/ | ||
| /*Vectors(double m_x, double m_y, double m_z) : x(m_x), y(m_y), z(m_z)//конструктор б |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обозначьте аргументы x, y, z. Про имена для полей я выше написал.
| return temp; | ||
| } | ||
|
|
||
| double Vectors::cosfunc(Vectors a, Vectors b)// косинус угла между векторами |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Метод должен принимать один параметр, второй вектор – это тот, для которого вызывается метод.
| double tempa; | ||
| double tempb; | ||
| double result; | ||
| temp1 = a.x * b.x + a.y * b.y + a.x * b.z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для скалярного произведения использовать уже реализованный метод в классе.
| double tempb; | ||
| double result; | ||
| temp1 = a.x * b.x + a.y * b.y + a.x * b.z; | ||
| tempa = sqrt((pow(a.x, a.x) + pow(a.y, a.y) + pow(a.z, a.z))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
функция pow(N, a) – возводит число N в степень a.
| result = temp1 / (tempa * tempb); | ||
| return result; | ||
| } | ||
| double Vectors::scalcos(Vectors a, Vectors b)//нахождения косинуса угла между |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оставьте одну функцию для нахождения скалярного произведения.
| double scalcos = temp * result; | ||
| return scalcos; | ||
| } | ||
| void Vectors::composition(Vectors a, Vectors b)//векторное произведение векторов |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Функция должна принимать один аргумент. Первый множитель для векторного произведения – это тот вектор, у которого вызывается метод, второй вектор – аргумент, передаваемый в метод.
Результат должен возвращаться из функции в виде вектора.
Complited task 1. Vector.