#include "Transform.h"

Scale::Scale(double x, double y, double z)
    : mX(x),
      mY(y),
      mZ(z)
{

}

bool Scale::isIdentity() const
{
    return mX == 1.0 && mY == 1.0 && mZ == 1.0;
}

bool Scale::isEqual(const Scale& scale) const
{
    return mX == scale.mX && mY == scale.mY && mZ == scale.mZ;
}

Transform::Transform(const Point& location, const Scale& scale, const Rotation& rotation)
    : mLocation(location),
      mScale(scale),
      mRotation(rotation),
      mMatrix(4, 4)
{

}

void Transform::applyPre(const Transform& transform)
{
    mLocation.move(transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ());
    mScale *= transform.getScale();
}

const Point& Transform::getLocation() const
{
    return mLocation;
}

const Scale& Transform::getScale() const
{
    return mScale;
}

const Rotation& Transform::getRotation() const
{
    return mRotation;
}

bool Transform::isEqual(const Transform& transform) const
{
    return (mLocation == transform.mLocation) && (mScale == transform.mScale) && (mRotation == transform.mRotation);
}

bool Transform::isIdentityTransform() const
{
    return mLocation.isAtOrigin() && mScale.isIdentity();
}

void Transform::setLocation(const Point& loc)
{
    if (mLocation != loc)
    {
        mLocation = loc;
        updateMatrix();
    }
}

void Transform::setScale(const Scale& scale)
{
    if (mScale != scale)
    {
        mScale = scale;
        updateMatrix();
    }
}

void Transform::setRotation(const Rotation& rotation)
{
    if (mRotation != rotation)
    {
        mRotation = rotation;
        updateMatrix();
    }
}

void Transform::updateMatrix()
{

}

