// This source code is property of the Computer Graphics and Visualization 
// chair of the TU Dresden. Do not distribute! 
// Copyright (C) CGV TU Dresden - All Rights Reserved
//
#include "AtomicTransform.h"

#include <cgv/math/transformations.h>
#include <libs/cgv_gl/gl/gl.h>

#include "math_helper.h"

void AtomicTransform::set_limits(double lower, double upper)
{
	this->lower_limit = lower;
	this->upper_limit = upper;
	this->value = 0;
}

void AtomicTransform::set_value(const double& value, void*)
{
	this->value = value;
	changed_signal(value);
}

std::string AtomicTransform::get_name() const { return title; }
const double AtomicTransform::get_value(void*) const { return value; }
const double AtomicTransform::get_lower_limit() const { return lower_limit; }
const double AtomicTransform::get_upper_limit() const { return upper_limit; }

AtomicRotationTransform::AtomicRotationTransform(Vec3 axis)
	: axis(axis)
{
	lower_limit = -180;
	upper_limit = 180;
	value = 0;
}

Mat4 AtomicRotationTransform::calculate_matrix()
{
	return rotate(axis, (float)value);	
}



void AtomicRotationTransform::optimize_value(const Vec3& local_vector, const Vec3& target, bool inverse)
{
	/*Task: Implement parameter optimization*/
}

AtomicTranslationTransform::AtomicTranslationTransform(int dim) 
	: dim(dim) 
{
	lower_limit = -10;
	upper_limit = 10;
}

Mat4 AtomicTranslationTransform::calculate_matrix()
{	
	Mat4 result;
	result.identity();
	result(dim, 3) = (float)value;	
	return result;
}

void AtomicTranslationTransform::optimize_value(const Vec3& local_vector, const Vec3& target, bool inverse)
{
}