矩阵/坐标变换顺序 [英] Matrix / coordinate transformation order

查看:323
本文介绍了矩阵/坐标变换顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个阵列点:

点[]原件; 点[]转化;

这些转化阵简直是原件及复印件与应用的转换。例如:

These transformed array is simply a copy of the original with transformations applied. Example:

matrix.Rotate(5f);  
matrix.Scale(.8f, 1.1f);  
matrix.Translate(30f, 18f);  
matrix.TransformPoints(transformed);




  • 原始分的

  • 转化值称。

  • 在其中应用了转换的顺序是众所周知的。

    • The original points ARE known.
    • The transformation values ARE known.
    • The order in which the transformations were applied is NOT known.
    • 我如何计算/推断变换的顺序?

      How can I calculate / infer the order of transformations?

      修改


      • 只有一个轮转化。

      • A轮可以包含最多三个转变如下图所示。

      • 应用唯一的转换是在旋转,缩放任意组合和翻译。

      要给它一些真实世界的背景下,考虑与利益已知点的图像。您打印图像,扫描,并尝试再次阅读。该图像包含方向标记,让我计算出在扫描过程中应用转换

      To give it some real-world context, consider having an image with known points of interest. You print the image, scan it and try to read it again. The image contains orientation markers that allow me to calculate the transformations applied during the scanning process.

      现在,蛮力的方法是:


      1. 阅读扫描的图像。

      2. 扫描图像计算转动。

      3. 在应用旋转扫描的图像。

      4. 旋转的图像上计算的规模。

      5. 应用规模旋转图像。

      6. 计算平移缩放后的图像上。

      7. 缩放后的图像上应用的翻译。

      1. Read scanned image.
      2. Calculate rotation on the scanned image.
      3. Apply rotation on the scanned image.
      4. Calculate scale on the rotated image.
      5. Apply scale on the rotated image.
      6. Calculate translation on the scaled image.
      7. Apply translation on the scaled image.

      您现在可以从处理后的图像使用原始点作为如果没有变换阅读的兴趣点。当然这种方法是昂贵的。一个500MB的图像需要同时在内存中拥有至少两个拷贝,就必须使用图形对象转化。

      You can now read the points of interest from the processed image using the original points as if there was no transformation. Of course this method is expensive. A 500MB image would need to have at least two copies in memory at a time and would have to be transformed using the graphics object.

      这个问题的前提是阅读图像只有一次,计算所有转换和应用它们来协调,而不是图像本身。在使用该转换后的坐标读取的兴趣点。这就是的变换的秩序问题的用武之地。下面一些非常有用的答案,我希望这将清除环境。

      The premise of this question was to read the image only once, calculate all transformations and apply them to coordinates rather than the image itself. The use the transformed coordinates to read the points of interest. This is where the problem of 'order of transformations' comes in. Some very helpful answers below and I hope this clears the context.

      推荐答案

      对于您正在寻找蛮力转化的数量可能是最简单的方法,而不是试图做的事情的数学分析(我不是100%肯定,如果这甚至有可能,但是这将是非常困难)。

      For the number of transformations that you are looking at brute force is probably the easiest approach rather than trying to do any mathematical analyses on things (I'm not 100% sure if that's even possible but it would be very hard).

      有关三种不同的变换(A,b,C)有六个不同的方法可以应用它们。它们是:

      For three different transforms (A,B,C) you have six different ways you can apply them. They are:


      • ABC

      • ACB

      • BAC

      • BCA

      • CAB

      • CBA

      • ABC
      • ACB
      • BAC
      • BCA
      • CAB
      • CBA

      因此,对于每一个这样的顺序将其应用到输入和检查最终产品是否你的输出相匹配。

      So for each of those apply them in that order to your input and check whether the final product matches your output.

      如果您还没有具体的转换,那么你只剩下两个顺序选项之一。这可以通过只是使用上述六个选项并施加一个单位矩阵(或者无操作),其中丢失的变换是最好的处理。当然,你还需要检查,以防止你重复相同的转换顺序

      If you don't have one of the specific transforms then you are left with only two options of order. This may be best dealt with by just using the above six options and applying an identity matrix (or a no-op) where the missing transform is. Of course you also need checks to prevent you from duplicating the same transform order.

      为了获得最佳性能,你不一定需要检查所有的点阵列中 - 如果第一点不匹配,那么无需检查任何更多。当然,你将要检查所有的点的阵列任何比赛,在确保其不只是偶然的,第一点改造工程。您还可以检查琐碎的转换(如按1倍的规模),并把他们当作不存在,因为它们可以在任何位置出现在所有的,所以你不妨假设他们是在开始(或结束或中 - 个人偏好)。

      For optimal performance you don't necessarily need to check all the points in your array - if the first point doesn't match then no need to check any more. You will of course want to check all of the points in the array for any that match to ensure that its not just by chance that the first point transformed that works. Also you can check for trivial transformations (such as scale by a factor of 1) and treat them as not existing because they could appear at any position at all so you might as well assume they are at the beginning (or end or middle - personal preference).

      最后仍有歧义的可能性。它不太可能和甚至一小部分的输入点就变得不太可能。这是你需要知道的,虽然一个点。另请参见下面的在哪里歧义成为了很多更容易特殊情况的讨论。

      Lastly there is still a possibility of ambiguity. its not very likely and with even a small set of input points it becomes very unlikely. It is a point you need to be aware of though. Also see below for discussion on special case where ambiguity becomes a lot more likely.

      我希望这是足以让你在正确的方向前进。因为我不知道你的转换数据如何存储等我写不出完整的代码。

      I hope this is enough to get you going in the right direction. I can't write full code because I have no idea how your transformation data is stored and so on.

      在对某些译文是否是可交换的,或不是一些简单的讨论(例如,在做A则B一样做B,则A)我相信他们不是。在其中X和Y的比例是相等的则缩放和旋转是可交换的,但这里所使用的语法表明缩放有两个因素我假定为X和Y的比例因子的特殊情况。这意味着,缩放和旋转不在这种情况下可交换的。翻译是永远不会交换(想象中的琐碎情况下翻译会的点移动到原点,你可以看到它的问题)。

      After some brief discussion about whether certain translation are commutative or not (eg is doing A then B the same as doing B then A) I believe that they are not. In the special case where the scaling of X and Y are equal then scaling and rotation are commutative but the syntax used here suggests that scaling has two factors that I presume to be X and Y scale factors. This means that scaling and rotation are not commutative in this case. Translations are never commutative (imagine the trivial case where a translation would move the point to the origin and you can see that it matters).

      夜曲的点(评论)上可交换不适用但如果规模X上同一轴和Y轴。这意味着,如果你有这样的规模和它旁边的旋转,那么你将得到两个可能的改造订单是有效的。将没有办法在两者之间进行区分。

      Nocturn's point (in comments) on commutativity does apply though if the scale is the same on X and Y axes. This means that if you have such a scale and it is next to a rotation then you will get two possible transformation orders that are valid. There will be no way to distinguish between the two.

      这篇关于矩阵/坐标变换顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆