in reply to Re^11: 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?

I must confess I just took took the difference between the first and last Cartesian co-ordinates and multiplied it by the inverse of the distance? as below? I just assumed it would do?
$Xl1 = -3.901 $Yl1 = 9.352 $Zl1 = -1.557 $Xl2 = -47.430 $Yl2 = -2.993 $Zl2 = -17.639 $Axx = $Xl1 - $Xl2; $Axy = $Yl1 - $Yl2; $Axz = $Zl1 - $Zl2; $Vform = V($Axx,$Axy,$Axz); $vector = sqrt($Axx**2 + $Axy**2 + $Axz**2); $Unitvector = 1/$vector * $Vform;

best wishes Dan

  • Comment on Re^12: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
  • Download Code

Replies are listed 'Best First'.
Re^13: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
by BrowserUk (Patriarch) on Jul 02, 2012 at 19:21 UTC

    Okay. That explains a lot. The coordinates you've used above for the last point:

    $Xl2 = -47.430 $Yl2 = -2.993 $Zl2 = -17.639

    are different from those you supplied in Re^4: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?:

    ATOM CA GLY A 101 -50.317 -4.262 -17.720

    When I do the same thing using the line data from that post:

    #! perl -slw use strict; use constant { X=>0, Y=>1, Z=>2, W=>3 }; my @first = ( -3.901, ,9.352, ,-1.557 ); my @last = ( -50.317, -4.262, -17.720 ); my @v = ( $last[X] - $first[X], $last[Y] - $first[Y], $last[Z] - $first[Z], ); my $l = sqrt( $v[X]**2 + $v[Y]**2 + $v[Z]**2 ); my @unitVec = map $_ / $l, @v; print "@unitVec"; __END__ [20:14:31.75] C:\test>unitVec.pl -0.910112639703537 -0.266939707793087 -0.316919824963984

    And put those in place of your supplied unit vector:0.906 0.258 0.335 and re-run the transforms, I get much better correspondence between rotation axis and the Z-axis:

    [20:10:08.00] C:\test>979082 -LIM4A=15 [ [0, 0, "1.54737342767147"], [ "1.06484137623042e-005", "-1.2776161742778e-005", "4.54810050618 +484"], [ "0.000325405667775502", "0.000255895356081837", "7.54791747205 +851"], ["-0.000219093060060072", "-0.000435009701289957", "10.54715057839 +94" ], ["-0.000208444646297323", "-0.000447785863032735", "13.54787765691 +28" ], [ "0.000106312607715875", "-0.000179114345206344", "16.54769462278 +65" ], [ "0.000421069861728629", "8.95571726164945e-005", "19.54751158866 +01" ], ["-0.000516734055701296", "7.67810108754929e-005", "22.54792174734 +85" ], ["-0.000201976801687653", "0.000345452528700108", "25.54773871322 +22" ], [ "0.00020197680166989", "-0.000345452528671686", "28.54728873938 +81" ], [ "0.000212625215433082", "-0.000358228690412687", "31.54801581790 +14" ], ["-0.000421069861747281", "-8.95571725898492e-005", "34.54751586395 +01" ], ["-0.000410421447985865", "-0.000102333334330851", "37.54824294246 +35" ], ["-9.56641939722225e-005", "0.000166338183491987", "40.54805990833 +72" ], ["-0.000640162921804244", "-0.000524566873879806", "43.54729301467 +81" ], ["-0.000629514508044604", "-0.000537343035622584", "46.54802009319 +14" ], ["-0.000314757254034514", "-0.000268671517799746", "49.54783705906 +51" ], ["-1.73194791841524e-014", "2.66453525910038e-014", "52.54765402493 +88" ], ]

    That's much more satisfying :)

    And the affect that has on the collision results are small, but I think significant:

    [20:19:34.18] C:\test>979082 -LIM4A=15 R: 0 [ -18.731, -0.135, -11.272 ] [ 6.260, 52° +] S:259 angle: -58.482° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 5 [ -18.388, -2.409, -9.308 ] [ 7.454, 75° +] S:259 angle: -35.177° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 6 [ -18.784, -3.016, -7.671 ] [ 7.681, 89° +] S:259 angle: -21.699° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 7 [ -17.107, -3.128, -6.966 ] [ 8.259, 90° +] S:245 angle: -27.682° [ -5.672, 3.533, 0.140 ] [ 5.742, 118° +] S:256 angle: -23.655° [ -5.562, 1.600, 0.400 ] [ 7.610, 114° +] S:257 angle: -22.479° [ -5.970, 0.493, 0.400 ] [ 8.569, 112° +] S:258 angle: -22.287° [ -5.825, 0.591, 0.400 ] [ 8.500, 112° +] S:259 angle: -20.441° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] S:254 angle: -20.325° [ -4.738, 1.093, 0.400 ] [ 8.200, 110° +] S:255 angle: -20.193° [ -4.814, 0.899, 0.400 ] [ 8.368, 110° +] S: 7 angle: -12.398° [ -3.823, -2.789, 0.030 ] [ 11.951, 102° +] R:140 [ -18.510, -10.387, -3.385 ] [ 15.488, 107° +] S:259 angle: -3.661° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R:141 [ -17.411, -10.096, -2.922 ] [ 15.540, 107° +] S:256 angle: -6.629° [ -5.562, 1.600, 0.400 ] [ 7.610, 114° +] S:257 angle: -5.453° [ -5.970, 0.493, 0.400 ] [ 8.569, 112° +] S:258 angle: -5.261° [ -5.825, 0.591, 0.400 ] [ 8.500, 112° +] S:259 angle: -3.414° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +]

    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.

    The start of some sanity?