in reply to Re^5: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
in thread Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
Hello
Apologies I'm really struggling to understand what you mean? any chance you could give me an equation or example code so I can get my head around it please?
many thanks and best wishes
Dan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
by BrowserUk (Patriarch) on Jun 29, 2012 at 20:45 UTC | |
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:
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:
And now we can convert the 3D cartesian points, to 2D polar vectors:
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".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by fraizerangus (Sexton) on Jun 30, 2012 at 12:29 UTC | |
Hello Thanks so much for your help! Its much appreciated! Once this wedding is over I will sit down and have a read! :) Just to put things in perspective if you download Jmol (http://jmol.sourceforge.net/download/) a molecular viewer and then copy this code into a text document and then open it in Jmol you'll see the test molecule, the blue balls are the co-ordinates I need to rotate around the axis (in grey) until they come into a distance of 4A of the red and then rotate in the other direction until it does the same
best wishes and many thanks Dan | [reply] [d/l] |
by BrowserUk (Patriarch) on Jul 02, 2012 at 13:28 UTC | |
until they come into a distance of 4A What is the distance "4A", in the units used by the data? 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".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by fraizerangus (Sexton) on Jul 02, 2012 at 16:46 UTC | |
by BrowserUk (Patriarch) on Jul 02, 2012 at 17:49 UTC | |
| |
by BrowserUk (Patriarch) on Jul 02, 2012 at 17:03 UTC | |
Here's the code I promised: <Reveal this spoiler or all in this thread>
And output from a sample run with the 4A limit set manually to an arbitrary value that produces limited output:
As you can see, the run takes around 1/2 a second to process the 146 rotation points against the 254 stop point of your sample data. The runtime will be linear in the number of points. The output shows that rotatable point 5 [original 3D cartesian coords] [2D polar coords (radius/angle) about z-axis] will collide with stop point 259 after being rotated 32.607°</c> Rot point: 6 will collide with stop point 6 after being rotated 19.401°. Rot point 7 will collide with stop point 7 after being rotated 10.377°, and stop point 245 after being rotated 334.204° the opposite way. And so on. 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".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |