MikeRohsoft icon

Untitled

MikeRohsoft | PRO | 05/15/17 05:21:35 PM UTC | 0 ⭐ | 430 👁️ | Never ⏰ | []
C++ |

2.75 KB

|

None

|

0 👍

/

0 👎

class Vector3
{
public:
    float x;
    float padding_0;
    float y;
    float padding_1;
    float z;
    float padding_2;
    Vector3()
    {
 
    }
    Vector3(float x, float y, float z)
    {
        Vector3::x = x;
        Vector3::y = y;
        Vector3::z = z;
    }
    Vector3 operator+(const Vector3& v)
    {
        Vector3 vec;
        vec.x = this->x + v.x;
        vec.y = this->y + v.y;
        vec.z = this->z + v.z;
        return vec;
    }
    Vector3 operator+(const float& v)
    {
        Vector3 vec;
        vec.x = this->x + v;
        vec.y = this->y + v;
        vec.z = this->z + v;
        return vec;
    }
    Vector3& operator+=(const float v)
    {
        this->x += v;
        this->y += v;
        this->z += v;
        return *this;
    }
    Vector3 operator+=(const Vector3& v)
    {
        this->x += v.x;
        this->y += v.y;
        this->z += v.z;
        return *this;
    }
    Vector3 operator-(const Vector3& v)
    {
        Vector3 vec;
        vec.x = this->x - v.x;
        vec.y = this->y - v.y;
        vec.z = this->z - v.z;
        return vec;
    }
    Vector3 operator-(const float& v)
    {
        Vector3 vec;
        vec.x = this->x - v;
        vec.y = this->y - v;
        vec.z = this->z - v;
        return vec;
    }
    Vector3& operator-=(const float v)
    {
        this->x -= v;
        this->y -= v;
        this->z -= v;
        return *this;
    }
    Vector3 operator-=(const Vector3& v)
    {
        this->x -= v.x;
        this->y -= v.y;
        this->z -= v.z;
        return *this;
    }
    Vector3 operator*(const Vector3& v)
    {
        Vector3 vec;
        vec.x = this->x * v.x;
        vec.y = this->y * v.y;
        vec.z = this->z * v.z;
        return vec;
    }
    Vector3 operator*(const float& v)
    {
        Vector3 vec;
        vec.x = this->x * v;
        vec.y = this->y * v;
        vec.z = this->z * v;
        return vec;
    }
    Vector3& operator*=(const float v)
    {
        this->x *= v;
        this->y *= v;
        this->z *= v;
        return *this;
    }
    Vector3 operator*=(const Vector3& v)
    {
        this->x *= v.x;
        this->y *= v.y;
        this->z *= v.z;
        return *this;
    }
    Vector3 operator/(const Vector3& v)
    {
        Vector3 vec;
        vec.x = this->x / v.x;
        vec.y = this->y / v.y;
        vec.z = this->z / v.z;
        return vec;
    }
    Vector3 operator/(const float& v)
    {
        Vector3 vec;
        vec.x = this->x / v;
        vec.y = this->y / v;
        vec.z = this->z / v;
        return vec;
    }
    Vector3& operator/=(const float v)
    {
        this->x /= v;
        this->y /= v;
        this->z /= v;
        return *this;
    }
    Vector3 operator/=(const Vector3& v)
    {
        this->x /= v.x;
        this->y /= v.y;
        this->z /= v.z;
        return *this;
    }
    int size(const Vector3& v)
    {
        double x = (double)v.x;
        double y = (double)v.y;
        double z = (double)v.z;
        return (int)sqrt(x*x + y*y + z*z);
    }
};
 
class CVector3
{
public:
    float x, y, z;
    CVector3()
    {
 
    }
    CVector3(float x, float y, float z)
    {
        CVector3::x = x;
        CVector3::y = y;
        CVector3::z = z;
    }
    explicit operator Vector3() const
    {
        return Vector3(this->x, this->y, this->z);
    }
};

Comments