Basic optimize value

This commit is contained in:
hodasemi 2018-06-21 14:55:40 +02:00
parent 5a44143a75
commit 2b8aa08367
3 changed files with 22 additions and 5 deletions

View file

@ -190,15 +190,30 @@ void AtomicRotationTransform::optimize_value(const Vec3 &local_vector, const Vec
// optimize this that: target = this->calculate_matrix() * local_vector;
float first_guess = angle(local_vector, target);
double result = 0.0;
double result = least_squares(local_vector, target, first_guess);
Vec3 lp = local_vector - (dot(local_vector, axis) * axis);
Vec3 tp = target - (dot(target, axis) * axis);
result = (double)angle(lp, tp);
result = result * 180 / PI;
//std::cout << "angle before bounds check: " << result << std::endl;
//float first_guess = angle(local_vector, target);
//double result = least_squares(local_vector, target, first_guess);
if (inverse)
result = -result;
result = clamp(result, lower_limit, upper_limit);
//std::cout << "angle after bounds check: " << result << std::endl;
set_value(result);
}

View file

@ -218,6 +218,8 @@ void IKViewer::optimize()
/*Task 3.3: Implement CCD */
for (int i = 0; i < max_iterations; i++)
{
std::cout << "iteration: " << i << std::endl;
int kc_size = kinematic_vector.size();
// reverse iterate through kinematic chain