#pragma once

#include "Rotation.h"

struct Scale
{
    Scale(double x = 1.0, double y = 1.0, double z = 1.0);

    bool isIdentity() const;

    bool isEqual(const Scale& scale) const;

    void operator*=(const Scale& rhs)
     {
        mX *= rhs.mX;
        mY *= rhs.mY;
        mZ *= rhs.mZ;
     }

    bool operator==(const Scale& rhs) const
    {
       return isEqual(rhs);
    }

    bool operator!=(const Scale& rhs) const
    {
      return !operator==(rhs);
    }

    double mX{1.0};
    double mY{1.0};
    double mZ{1.0};
};

class Transform
{
public:
    Transform(const Point& location = {}, const Scale& scale = {}, const Rotation& rotation = {});

    void applyPre(const Transform& transform);

    const Point& getLocation() const;

    const Scale& getScale() const;

    const Rotation& getRotation() const;

    const Matrix& getMatrix() const;

    bool isEqual(const Transform& transform) const;

    bool isIdentityTransform() const;

    void setLocation(const Point& loc);

    void setScale(const Scale& scale);

    void setRotation(const Rotation& rotation);

    bool operator==(const Transform& rhs) const
    {
       return isEqual(rhs);
    }

    bool operator!=(const Transform& rhs) const
    {
      return !operator==(rhs);
    }

private:
    void updateMatrix();

    Point mLocation;
    Scale mScale;
    Rotation mRotation;
    Matrix mMatrix;
};
