I'll try to clarify the approach with some 2D ascii art.
Here is a diagram of the problem simplified so that we have 1 input point (x); 4 stopping points (o); and the rotational axis (+).
Fortuitously, in this example all the z values are 0; and the axis of rotation happens to be parallel to the z-axis:
+ Axis of rotation: [-5, -2, *]
x An input point to be rotated [+1, -2, *]
o Several stopping points: [-7, +4, *]
[-6, +3, *]
[-5, +5, *]
[-4, +4, *]
o 5
o o |
o |
|
|
- - - 5 - - - - 0 - - - - 5 - - - -
|
+ | x
|
|
5
Using your described approach, you now have to rotate (x) around (+) and then compare the new position with each of the 4 (o)s; and do that 360 times. Or more, depending upon your allowable tolerance.
In this example it is easy to see that by applying a simple translation transform to all the points, we can re-base the coordinates, and thus slide the z-axis until it is coincident with the axis of rotation. The 2D transform required is just [+5, +2], giving the points: + Axis of rotation: [ 0, 0, *]
x An input point to be rotated [+6, 0, *]
o Several stopping points: [-2, +6, *]
[-1, +5, *]
[ 0, +7, *]
[+1, +6, *]
|
o
o | o
o 5
|
|
|
|
- - - + - - - - 5 x
|
|
|
And now we can convert the 3D cartesian points, to 2D polar vectors: [radius, angle]
x An input point to be rotated [+6, 0, *] -> [6.00, 0.000]
o Several stopping points: [-2, +6, *] -> [6.32, 108.4]
[-1, +5, *] -> [5.09, 101.3]
[ 0, +7, *] -> [7.00, 90.0]
[+1, +6, *] -> [6.08, 80.5]
And it is easy to see that if our tolerance on the radius, for a collision, were 0.1, then we only need look at 1 of the 4 stopping points.
And we can directly obtain the rotation required to produce that collision by subtracting the angles. In this case 80.5 degrees.
Obviously, real data is not so convenient, and the transform you'll need to apply to the points to align the axis of rotation with the z-axis will need to be a full Affine transform. But with the unit vector for the axis of rotation, you already have the major information required to construct it.
The other part of the matrix will require you to find the closest point on the axis of rotation to the origin; in order to fill in the x,y,z translation values. But as I recall, that is simply derived directly from the equation of the axis, which is derived directly from is unit vector.
But the major point is, once you have transformed the points to align the axis, you can exclude the z-coordinates and use 2D vectors to avoid having to iterate the rotation or do a full input points to stopping point cross comparison. You only need consider the z values again once you've found pairs that have the same radius in the X-Y plane.
I'll need to refresh my memory of the math involved -- I always do -- but I'll try to post a worked example over the weekend.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|