You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

#ifndef VECTOR3_HPP
#define VECTOR3_HPP
#include <cmath>
#include <iostream>
class Vector3 {
private:
float x_, y_, z_;
public:
Vector3(float x = 0, float y = 0, float z = 0) : x_(x), y_(y), z_(z) {}
// Vector3(float x, float y, float z) : x_(x), y_(y), z_(z) {}
// ������
float x() const { return x_; }
float y() const { return y_; }
float z() const { return z_; }
// �����
Vector3 operator+(const Vector3& v) const;
Vector3 operator-(const Vector3& v) const;
Vector3 operator*(float s) const;
Vector3 operator/(float s) const;
Vector3 operator-() const;
void setX(float x) { x_ = x; }
void setY(float y) { y_ = y; }
void setZ(float z) { z_ = z; }
// ��������
float dot(const Vector3& v) const;
Vector3 cross(const Vector3& v) const;
float norm() const;
float normSquared() const;
Vector3 normalized() const;
// �Ƚ�
bool operator==(const Vector3& v) const;
bool operator!=(const Vector3& v) const;
// ���
friend std::ostream& operator<<(std::ostream& os, const Vector3& v);
};
// ��������������������ת�������޵����˹��ת��ʽ��
Vector3 rotateAroundAxis(const Vector3& v, const Vector3& axis, float angle);
#endif