monte carlo 6D 采样 space

monte carlo sampling in 6D space

我正在为两个对象(A 和 B)的刚体叠加编写 java 代码。对象 A 在 space 中固定,而对象 B 在 space 中自由移动。目标是获得 A 和 B 之间的最佳匹配。

为了找到 A 和 B 之间的最佳拟合,我想对 B 的可能姿势进行采样。为此,我正在尝试实施基于蒙特卡洛的采样程序。但是我不确定我是否以正确的方式进行操作。我阅读了 google 上的几篇文章,但我对随机变量的概率分布和移动接受标准有点困惑。

由于物体B可以在space内进行平移和旋转,我定义了6个变量(6D space)分别对应x,y,z的平移和旋转。我做了 50000 次随机移动。每次移动后,我都会检查 A 和 B 的新姿势之间是否适合。下面是我现在正在使用的简化 java 代码。

object A;
object B;
object B_NewPose;
double winnerScore;

for (int iter = 0; iter < 50000; iter++) {

    double x_tranlation = 0; //translate in X (max translation is +-10 Amstrong)
    double y_tranlation = 0; //translate in Y (max translation is +-10 Amstrong)
    double z_tranlation = 0; //translate in Z (max translation is +-10 Amstrong)

    double x_rotation = 0; //rotate around X (max rotation is 360 degree)
    double y_rotation = 0; //rotate around Y (max rotation is 360 degree)
    double z_rotation = 0; //rotate around Z (max rotation is 360 degree)

    //random selection of the axes for translation and rotation
    int axis_Idx = getRanNumberInt(0, 2); // (0=x, 1=y and 2=z)

    //get the amount of translation (can be right (+) or left(-))
    double translate = getRanNumberDouble(0, 10);
    if (axis_Idx==0) {
       x_tranlation=translate;  
    }

    if (axis_Idx==1) {
       y_tranlation=translate;  
    }

    if (axis_Idx==2) {
       z_tranlation=translate;  
    }

    //get the amount of rotation
    double rotation = getRanNumberDouble(0, 360);
    if (axis_Idx==0) {
       x_rotation=rotation; 
    }

    if (axis_Idx==1) {
       y_rotation=rotation; 
    }

    if (axis_Idx==2){
       z_rotation=rotation; 
    }

    //Now move the object: translation and rotation
    B_NewPose= moveTheObj(object B, x_tranlation, y_tranlation, z_tranlation, x_rotation, y_rotation, z_rotation);

    //Check how good is the fit between A and N_NewPose
    double score = calculateFit(A, B_NewPose);

    if (score> oldScore){
        oldScore=score;
        B=B_NewPose;                
    }

    }

如果有人能指导我正确的方向或帮助我阐明这个场景中的蒙特卡洛算法,我将不胜感激。 非常感谢。

翻译看起来不错,它们是线性的

wrt 旋转,我不确定它在球体上是否均匀。因此,您可能会考虑这样一种情况,即您可能只需要对象的随机方向,因为您并不真正关心旧方向是否重要

为此,生成新对象的算法非常简单 axis/orientation 位置

phi   = 2.0 * PI * getRanNumberDouble(0.0, 1.0);
csth  = 2.0 * getRanNumberDouble(0.0, 1.0) - 1.0;
snth  = sqrt((1.0 - csth)*(1.0 + csth));
wx = snth * sin(phi);
wy = snth * cos(phi);
wz = csth;

这将为您提供归一化向量 (wx, wy, wz),这将是您的新对象 orientation/axis。 如果你真的需要随机旋转,你可能想要像上面的方法一样采样球体上的均匀向量旋转,并添加旋转角度

angle = 2.0 * PI * getRanNumberDouble(0.0, 1.0);

那么(wx, wy, wz, angle)基本上是一个均匀分布的四元数,你可以用它来构建旋转操作(使用四元数,或者用它制作矩阵或罗德里格斯公式,无论你喜欢什么)。

我正在使用弧度