Erste ableitung
This commit is contained in:
parent
c2ee2a5909
commit
5a44143a75
1 changed files with 25 additions and 10 deletions
|
@ -149,24 +149,39 @@ float j(float rcos, float z)
|
|||
|
||||
float AtomicRotationTransform::least_squares(const Vec3 &local_vector, const Vec3 &target, float r)
|
||||
{
|
||||
float angler = r * PI / 180.0f;
|
||||
float pii = PI;
|
||||
float hundertachtzig = 180.0f;
|
||||
|
||||
float rcos = cos(angler);
|
||||
float rsin = sin(angler);
|
||||
float angle = r * pii / hundertachtzig;
|
||||
|
||||
float rcos = cos(angle);
|
||||
float rsin = sin(angle);
|
||||
|
||||
float x = axis.x();
|
||||
float y = axis.y();
|
||||
float z = axis.z();
|
||||
|
||||
float xs = a(rcos, x) * local_vector.x() + b(rcos, rsin, x, y, z) * local_vector.y() + c(rcos, rsin, x, y, z) * local_vector.z();
|
||||
float ys = d(rcos, rsin, x, y, z) * local_vector.x() + e(rcos, y) * local_vector.y() + f(rcos, rsin, x, y, z) * local_vector.z();
|
||||
float zs = g(rcos, rsin, x, y, z) * local_vector.x() + h(rcos, rsin, x, y, z) * local_vector.y() + j(rcos, z);
|
||||
float xt = target.x();
|
||||
float yt = target.y();
|
||||
float zt = target.z();
|
||||
|
||||
float x_diff = xs - target.x();
|
||||
float y_diff = ys - target.y();
|
||||
float z_diff = zs - target.z();
|
||||
float xl = local_vector.x();
|
||||
float yl = local_vector.y();
|
||||
float zl = local_vector.z();
|
||||
|
||||
float squares = x_diff * x_diff + y_diff * y_diff + z_diff * z_diff;
|
||||
float xs = a(rcos, x) * xl + b(rcos, rsin, x, y, z) * yl + c(rcos, rsin, x, y, z) * zl;
|
||||
float ys = d(rcos, rsin, x, y, z) * xl + e(rcos, y) * yl + f(rcos, rsin, x, y, z) * zl;
|
||||
float zs = g(rcos, rsin, x, y, z) * xl + h(rcos, rsin, x, y, z) * yl + j(rcos, z) * zl;
|
||||
|
||||
float x_diff = xs - xt;
|
||||
float y_diff = ys - yt;
|
||||
float z_diff = zs - zt;
|
||||
|
||||
float squares = std::sqrt(x_diff * x_diff + y_diff * y_diff + z_diff * z_diff);
|
||||
|
||||
float first_diff = 2 * (xl * ((pii * sin((pii * r) / hundertachtzig)) / hundertachtzig - (pii * x * x * sin((pii * r) / hundertachtzig)) / hundertachtzig) + yl * ((pii * z * cos((pii * r) / hundertachtzig)) / hundertachtzig - (pii * x * y * sin((pii * r) / hundertachtzig)) / hundertachtzig) - zl * ((pii * y * cos((pii * r) / hundertachtzig)) / hundertachtzig + (pii * x * z * sin((pii * r) / hundertachtzig)) / hundertachtzig)) * (xt - xl * ((1 - cos((pii * r) / hundertachtzig)) * x * x + cos((pii * r) / hundertachtzig)) + yl * (z * sin((pii * r) / hundertachtzig) + x * y * (cos((pii * r) / hundertachtzig) - 1)) - zl * (y * sin((pii * r) / hundertachtzig) - x * z * (cos((pii * r) / hundertachtzig) - 1))) + 2 * (zl * ((pii * sin((pii * r) / hundertachtzig)) / hundertachtzig - (pii * z * z * sin((pii * r) / hundertachtzig)) / hundertachtzig) + xl * ((pii * y * cos((pii * r) / hundertachtzig)) / hundertachtzig - (pii * x * z * sin((pii * r) / hundertachtzig)) / hundertachtzig) - yl * ((pii * x * cos((pii * r) / hundertachtzig)) / hundertachtzig + (pii * y * z * sin((pii * r) / hundertachtzig)) / hundertachtzig)) * (zt + xl * (y * sin((pii * r) / hundertachtzig) + x * z * (cos((pii * r) / hundertachtzig) - 1)) - yl * (x * sin((pii * r) / hundertachtzig) - y * z * (cos((pii * r) / hundertachtzig) - 1)) - zl * ((1 - cos((pii * r) / hundertachtzig)) * z * z + cos((pii * r) / hundertachtzig))) + 2 * (xl * ((pii * z * cos((pii * r) / hundertachtzig)) / hundertachtzig + (pii * x * y * sin((pii * r) / hundertachtzig)) / hundertachtzig) - yl * ((pii * sin((pii * r) / hundertachtzig)) / hundertachtzig - (pii * y * y * sin((pii * r) / hundertachtzig)) / hundertachtzig) + zl * ((pii * y * cos((pii * r) / hundertachtzig)) / hundertachtzig + (pii * x * z * sin((pii * r) / hundertachtzig)) / hundertachtzig)) * (yl * ((1 - cos((pii * r) / hundertachtzig)) * y * y + cos((pii * r) / hundertachtzig)) - yt + xl * (z * sin((pii * r) / hundertachtzig) - x * y * (cos((pii * r) / hundertachtzig) - 1)) + zl * (y * sin((pii * r) / hundertachtzig) - x * z * (cos((pii * r) / hundertachtzig) - 1)));
|
||||
|
||||
return squares;
|
||||
}
|
||||
|
||||
void AtomicRotationTransform::optimize_value(const Vec3 &local_vector, const Vec3 &target, bool inverse)
|
||||
|
|
Loading…
Reference in a new issue