Skip to content

Conversation

@Anatolyvgy
Copy link

Complited task 1. Vector.

Complited task 1. Vector.

class Vectors
{
public:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставьте только методы публичными, данные сделайте приватными

{
public:

double x;
Copy link
Owner

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)// конструктор а
Copy link
Owner

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() // на всякий случай
Copy link
Owner

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)//конструктор б
Copy link
Owner

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)// косинус угла между векторами
Copy link
Owner

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;
Copy link
Owner

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)));
Copy link
Owner

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)//нахождения косинуса угла между
Copy link
Owner

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)//векторное произведение векторов
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функция должна принимать один аргумент. Первый множитель для векторного произведения – это тот вектор, у которого вызывается метод, второй вектор – аргумент, передаваемый в метод.
Результат должен возвращаться из функции в виде вектора.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants